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.
 
 
Nick Fitzgerald 64d52d8735 Add three build profiles and infrastructure for their toml configuration 7 years ago
..
command Add three build profiles and infrastructure for their toml configuration 7 years ago
manifest Add three build profiles and infrastructure for their toml configuration 7 years ago
test Move test synchronization to tests, not in `wasm-pack` 7 years ago
binaries.rs Use a global cache for all downloaded binaries 7 years ago
bindgen.rs Add three build profiles and infrastructure for their toml configuration 7 years ago
build.rs Add three build profiles and infrastructure for their toml configuration 7 years ago
child.rs Replace internal `Error` with `failure::Error` 7 years ago
emoji.rs fix(build): rustc check emoji and fix 7 years ago
installer.rs refactor: Import self and use full module path for failure 7 years ago
lib.rs Add three build profiles and infrastructure for their toml configuration 7 years ago
lockfile.rs Fix wasm-bindgen if lib is renamed via `lib.name` 7 years ago
logger.rs refactor: Return failure::Error instead of wasm_pack::error::Error 7 years ago
main.rs Add "Error:" prefix to error messages 7 years ago
npm.rs Use `child::run` for spawning child processes everywhere 7 years ago
progressbar.rs Deny missing documentation 7 years ago
readme.rs chore: Run rustfmt 7 years ago
target.rs feature(test): Add a `wasm-pack test` subcommand 7 years ago

readme.rs

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

use failure;
use std::fs;
use std::path::Path;

use emoji;
use progressbar::Step;
use PBAR;

/// Copy the crate's README into the `pkg` directory.
pub fn copy_from_crate(path: &Path, out_dir: &Path, step: &Step) -> 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 msg = format!("{}Copying over your README...", emoji::DANCERS);
PBAR.step(step, &msg);
let crate_readme_path = path.join("README.md");
let new_readme_path = out_dir.join("README.md");
if let Err(_) = fs::copy(&crate_readme_path, &new_readme_path) {
PBAR.warn("origin crate has no README");
};
Ok(())
}