fork of https://github.com/rustwasm/wasm-pack for the needs of NextGraph.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Daniel Iisak Mikael Kristiansson fde85de5a6
add linux aarch64 to targets; bump binaryen vers.
11 months ago
..
build Rewrite wasm_target to use target-libdir 2 years ago
command Merge pull request #1348 from sigmaSd/patch-1 1 year ago
install add linux aarch64 to targets; bump binaryen vers. 11 months ago
manifest Merge branch 'master' into esm-type-and-main-in-package-json 1 year ago
test Select correct target for chromedriver 2 years ago
bindgen.rs Merge pull request #1279 from tomasol/fix-target-dir-in-bindgen 2 years ago
cache.rs Switch from failure to anyhow 2 years ago
child.rs Fix some typos 2 years ago
emoji.rs fix: typos in comments 4 years ago
generate.rs Update to Rust 2021 2 years ago
installer.rs Switch from failure to anyhow 2 years ago
lib.rs Restore --version command 2 years ago
license.rs Update to Rust 2021 2 years ago
lockfile.rs Fix some typos 2 years ago
main.rs chore: Run cargo fmt 2 years ago
npm.rs fix: removes `--always-auth` from `npm login` 2 years ago
progressbar.rs Update to Rust 2021 2 years ago
readme.rs Respect package.readme in Cargo.toml 2 years ago
stamps.rs Switch from failure to anyhow 2 years ago
target.rs feat: add support for macos aarch64 3 years ago
wasm_opt.rs Fix usage of locally installed `wasm-opt` 2 years ago

readme.rs

//! Generating `README` files for the packaged wasm.

use anyhow::{Context, Result};
use std::fs;
use std::path::Path;

use crate::manifest::CrateData;
use crate::PBAR;

/// Copy the crate's README into the `pkg` directory.
pub fn copy_from_crate(crate_data: &CrateData, path: &Path, out_dir: &Path) -> Result<()> {
assert!(
fs::metadata(path).ok().map_or(false, |m| m.is_dir()),
"crate directory should exist"
);
assert!(
fs::metadata(&out_dir).ok().map_or(false, |m| m.is_dir()),
"crate's pkg directory should exist"
);

let crate_readme_path = match crate_data.crate_readme() {
None => return Ok(()),
Some(readme_path) => path.join(readme_path),
};

let new_readme_path = out_dir.join("README.md");
if crate_readme_path.exists() {
fs::copy(&crate_readme_path, &new_readme_path).context("failed to copy README")?;
} else {
PBAR.warn("origin crate has no README");
}
Ok(())
}