This repository has been archived by the owner on Nov 8, 2021. It is now read-only.
forked from rustwasm/wasm-pack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into refactor-binary-installation
- Loading branch information
Showing
14 changed files
with
763 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
Make sure these boxes are checked! 📦✅ | ||
|
||
- [ ] You have the latest version of `rustfmt` installed and have your | ||
cloned directory set to nightly | ||
- [ ] You have the latest version of `rustfmt` installed | ||
```bash | ||
$ rustup override set nightly | ||
$ rustup component add rustfmt-preview --toolchain nightly | ||
``` | ||
- [ ] You ran `rustfmt` on the code base before submitting | ||
- [ ] You ran `cargo fmt` on the code base before submitting | ||
- [ ] You reference which issue is being closed in the PR text | ||
|
||
✨✨ 😄 Thanks so much for contributing to wasm-pack! 😄 ✨✨ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ flate2 = "1.0.2" | |
hex = "0.3" | ||
siphasher = "0.2.3" | ||
tar = "0.4.16" | ||
zip = "0.4.2" | ||
zip = "0.5.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//! Copy `LICENSE` file(s) for the packaged wasm. | ||
use failure; | ||
use std::fs; | ||
use std::path::Path; | ||
|
||
use emoji; | ||
use glob::glob; | ||
use manifest::CrateData; | ||
use progressbar::Step; | ||
use PBAR; | ||
|
||
fn glob_license_files(path: &Path) -> Result<Vec<String>, failure::Error> { | ||
let mut license_files: Vec<String> = Vec::new(); | ||
for entry in glob(path.join("LICENSE*").to_str().unwrap())? { | ||
match entry { | ||
Ok(globed_path) => { | ||
license_files.push(String::from( | ||
globed_path.file_name().unwrap().to_str().unwrap(), | ||
)); | ||
} | ||
Err(e) => println!("{:?}", e), | ||
} | ||
} | ||
Ok(license_files) | ||
} | ||
|
||
/// Copy the crate's license into the `pkg` directory. | ||
pub fn copy_from_crate( | ||
crate_data: &CrateData, | ||
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" | ||
); | ||
|
||
match crate_data.crate_license() { | ||
Some(_) => { | ||
let msg = format!("{}Copying over your LICENSE...", emoji::DANCERS); | ||
PBAR.step(step, &msg); | ||
let license_files = glob_license_files(path); | ||
|
||
match license_files { | ||
Ok(files) => { | ||
if files.len() == 0 { | ||
PBAR.info("License key is set in Cargo.toml but no LICENSE file(s) were found; Please add the LICENSE file(s) to your project directory"); | ||
return Ok(()); | ||
} | ||
for license_file in files { | ||
let crate_license_path = path.join(&license_file); | ||
let new_license_path = out_dir.join(&license_file); | ||
if let Err(_) = fs::copy(&crate_license_path, &new_license_path) { | ||
PBAR.info("origin crate has no LICENSE"); | ||
} | ||
} | ||
} | ||
Err(_) => PBAR.info("origin crate has no LICENSE"), | ||
} | ||
} | ||
None => { | ||
PBAR.step(step, "No LICENSE found in Cargo.toml, skipping..."); | ||
} | ||
}; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.