Skip to content

Commit 0f331e0

Browse files
Merge pull request #556 from rustwasm/revert-528
fix(manifest): LICENSE and README don't need to be whitelisted
2 parents da00ccd + cde16f1 commit 0f331e0

File tree

4 files changed

+19
-43
lines changed

4 files changed

+19
-43
lines changed

src/manifest/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,17 +430,13 @@ impl CrateData {
430430
None
431431
};
432432

433-
let readme_file = out_dir.join("README.md");
434-
if readme_file.is_file() {
435-
files.push("README.md".to_string());
436-
}
437-
438433
if let Ok(entries) = fs::read_dir(out_dir) {
439434
let file_names = entries
440435
.filter_map(|e| e.ok())
441436
.filter(|e| e.metadata().map(|m| m.is_file()).unwrap_or(false))
442437
.filter_map(|e| e.file_name().into_string().ok())
443-
.filter(|f| f.starts_with("LICENSE"));
438+
.filter(|f| f.starts_with("LICENSE"))
439+
.filter(|f| f != "LICENSE");
444440
for file_name in file_names {
445441
files.push(file_name);
446442
}

tests/all/license.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ fn it_copies_a_license_default_path() {
1717
let step = wasm_pack::progressbar::Step::new(1);
1818
assert!(license::copy_from_crate(&crate_data.unwrap(), &fixture.path, &out_dir, &step).is_ok());
1919

20-
let crate_license_path = fixture.path.join("LICENSE-WTFPL");
21-
let pkg_license_path = out_dir.join("LICENSE-WTFPL");
20+
let crate_license_path = fixture.path.join("LICENSE");
21+
let pkg_license_path = out_dir.join("LICENSE");
2222
println!(
2323
"wasm-pack: should have copied LICENSE from '{}' to '{}'",
2424
crate_license_path.display(),
@@ -42,10 +42,10 @@ fn it_copies_a_license_provided_path() {
4242

4343
let step = wasm_pack::progressbar::Step::new(1);
4444
assert!(license::copy_from_crate(&crate_data.unwrap(), &fixture.path, &out_dir, &step).is_ok());
45-
let crate_license_path = fixture.path.join("LICENSE-WTFPL");
46-
let pkg_license_path = out_dir.join("LICENSE-WTFPL");
45+
let crate_license_path = fixture.path.join("LICENSE");
46+
let pkg_license_path = out_dir.join("LICENSE");
4747
println!(
48-
"wasm-pack: should have copied LICENSE-WTFPL from '{}' to '{}'",
48+
"wasm-pack: should have copied LICENSE from '{}' to '{}'",
4949
crate_license_path.display(),
5050
pkg_license_path.display()
5151
);

tests/all/manifest.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::collections::HashSet;
33
use std::fs;
44
use std::path::PathBuf;
55
use utils::{self, fixture};
6-
use wasm_pack::{self, license, manifest, readme};
6+
use wasm_pack::{self, license, manifest};
77

88
#[test]
99
fn it_gets_the_crate_name_default_path() {
@@ -449,33 +449,3 @@ fn it_lists_license_files_in_files_field_of_package_json() {
449449
pkg.files,
450450
);
451451
}
452-
453-
#[test]
454-
fn it_lists_readme_in_files_field_of_package_json() {
455-
let fixture = utils::fixture::Fixture::new();
456-
fixture
457-
.readme()
458-
.hello_world_src_lib()
459-
.cargo_toml("readme-test-for-package-json");
460-
461-
let out_dir = fixture.path.join("pkg");
462-
463-
let crate_data = manifest::CrateData::new(&fixture.path).unwrap();
464-
465-
let step = wasm_pack::progressbar::Step::new(3);
466-
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap();
467-
readme::copy_from_crate(&fixture.path, &out_dir, &step).unwrap();
468-
crate_data
469-
.write_package_json(&out_dir, &None, false, "", &step)
470-
.unwrap();
471-
472-
let package_json_path = &fixture.path.join("pkg").join("package.json");
473-
fs::metadata(package_json_path).unwrap();
474-
let pkg = utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
475-
476-
assert!(
477-
pkg.files.contains(&"README.md".to_string()),
478-
"README.md is not in files: {:?}",
479-
pkg.files,
480-
);
481-
}

tests/all/utils/fixture.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ impl Fixture {
6767
)
6868
}
6969

70+
/// Add `LICENSE` file to the fixture.
71+
pub fn license(&self) -> &Self {
72+
self.file(
73+
"LICENSE",
74+
r#"
75+
I'm a license!
76+
"#,
77+
)
78+
}
79+
7080
/// Add `WTFPL LICENSE` file to the fixture.
7181
pub fn wtfpl_license(&self) -> &Self {
7282
self.file(
@@ -662,7 +672,7 @@ pub fn single_license() -> Fixture {
662672
fixture
663673
.readme()
664674
.cargo_toml("single_license")
665-
.wtfpl_license()
675+
.license()
666676
.hello_world_src_lib();
667677
fixture
668678
}

0 commit comments

Comments
 (0)