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.
![]() |
6 years ago | |
---|---|---|
.. | ||
build | 6 years ago | |
command | 6 years ago | |
install | 6 years ago | |
manifest | 6 years ago | |
test | 6 years ago | |
bindgen.rs | 6 years ago | |
cache.rs | 6 years ago | |
child.rs | 6 years ago | |
emoji.rs | 6 years ago | |
generate.rs | 6 years ago | |
installer.rs | 6 years ago | |
lib.rs | 6 years ago | |
license.rs | 6 years ago | |
lockfile.rs | 6 years ago | |
main.rs | 6 years ago | |
npm.rs | 6 years ago | |
progressbar.rs | 6 years ago | |
readme.rs | 6 years ago | |
stamps.rs | 6 years ago | |
target.rs | 7 years ago | |
wasm_opt.rs | 6 years ago |
readme.rs
//! Generating `README` files for the packaged wasm.
use failure::{self, ResultExt};
use std::fs;
use std::path::Path;
use PBAR;
/// Copy the crate's README into the `pkg` directory.
pub fn copy_from_crate(path: &Path, out_dir: &Path) -> Result<(), failure::Error> {
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 = path.join("README.md");
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(())
}