fix(style): appease cargo fmt

master
Ashley Williams 7 years ago
parent 180c2386ad
commit 4d5c7b8b3a
  1. 8
      src/command/init.rs
  2. 12
      src/manifest.rs
  3. 36
      tests/manifest/main.rs

@ -161,7 +161,13 @@ impl Init {
fn step_create_json(&mut self, step: &Step, log: &Logger) -> Result<(), Error> { fn step_create_json(&mut self, step: &Step, log: &Logger) -> Result<(), Error> {
info!(&log, "Writing a package.json..."); info!(&log, "Writing a package.json...");
manifest::write_package_json(&self.crate_path, &self.scope, self.disable_dts, &self.target, step)?; manifest::write_package_json(
&self.crate_path,
&self.scope,
self.disable_dts,
&self.target,
step,
)?;
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
info!( info!(
&log, &log,

@ -80,9 +80,9 @@ impl CargoManifest {
}; };
let js_bg_file = if target == "nodejs" { let js_bg_file = if target == "nodejs" {
Some(format!("{}_bg.js", filename)) Some(format!("{}_bg.js", filename))
} else { } else {
None None
}; };
if let Some(s) = scope { if let Some(s) = scope {
@ -98,10 +98,10 @@ impl CargoManifest {
} }
match js_bg_file { match js_bg_file {
Some(ref js_bg_file) => { Some(ref js_bg_file) => {
files.push(js_bg_file.to_string()); files.push(js_bg_file.to_string());
} }
None => {} None => {}
} }
NpmPackage { NpmPackage {

@ -65,11 +65,10 @@ fn it_creates_a_package_json_default_path() {
assert_eq!(types, "wasm_pack.d.ts"); assert_eq!(types, "wasm_pack.d.ts");
let actual_files: HashSet<String> = pkg.files.into_iter().collect(); let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> = let expected_files: HashSet<String> = ["wasm_pack_bg.wasm", "wasm_pack.d.ts"]
["wasm_pack_bg.wasm", "wasm_pack.d.ts"] .iter()
.iter() .map(|&s| String::from(s))
.map(|&s| String::from(s)) .collect();
.collect();
assert_eq!(actual_files, expected_files); assert_eq!(actual_files, expected_files);
} }
@ -78,7 +77,7 @@ fn it_creates_a_package_json_provided_path() {
let step = wasm_pack::progressbar::Step::new(1); let step = wasm_pack::progressbar::Step::new(1);
let path = "tests/fixtures/js-hello-world".to_string(); let path = "tests/fixtures/js-hello-world".to_string();
wasm_pack::command::init::create_pkg_dir(&path, &step).unwrap(); wasm_pack::command::init::create_pkg_dir(&path, &step).unwrap();
assert!(manifest::write_package_json(&path, &None, false, "", &step).is_ok()); assert!(manifest::write_package_json(&path, &None, false, "", &step).is_ok());
let package_json_path = format!("{}/pkg/package.json", &path); let package_json_path = format!("{}/pkg/package.json", &path);
assert!(fs::metadata(package_json_path).is_ok()); assert!(fs::metadata(package_json_path).is_ok());
assert!(utils::read_package_json(&path).is_ok()); assert!(utils::read_package_json(&path).is_ok());
@ -87,10 +86,8 @@ fn it_creates_a_package_json_provided_path() {
assert_eq!(pkg.main, "js_hello_world.js"); assert_eq!(pkg.main, "js_hello_world.js");
let actual_files: HashSet<String> = pkg.files.into_iter().collect(); let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> = [ let expected_files: HashSet<String> = ["js_hello_world_bg.wasm", "js_hello_world.d.ts"]
"js_hello_world_bg.wasm", .iter()
"js_hello_world.d.ts",
].iter()
.map(|&s| String::from(s)) .map(|&s| String::from(s))
.collect(); .collect();
assert_eq!(actual_files, expected_files); assert_eq!(actual_files, expected_files);
@ -101,7 +98,9 @@ fn it_creates_a_package_json_provided_path_with_scope() {
let step = wasm_pack::progressbar::Step::new(1); let step = wasm_pack::progressbar::Step::new(1);
let path = "tests/fixtures/scopes".to_string(); let path = "tests/fixtures/scopes".to_string();
wasm_pack::command::init::create_pkg_dir(&path, &step).unwrap(); wasm_pack::command::init::create_pkg_dir(&path, &step).unwrap();
assert!(manifest::write_package_json(&path, &Some("test".to_string()), false, "", &step).is_ok()); assert!(
manifest::write_package_json(&path, &Some("test".to_string()), false, "", &step).is_ok()
);
let package_json_path = format!("{}/pkg/package.json", &path); let package_json_path = format!("{}/pkg/package.json", &path);
assert!(fs::metadata(package_json_path).is_ok()); assert!(fs::metadata(package_json_path).is_ok());
assert!(utils::read_package_json(&path).is_ok()); assert!(utils::read_package_json(&path).is_ok());
@ -110,10 +109,8 @@ fn it_creates_a_package_json_provided_path_with_scope() {
assert_eq!(pkg.main, "scopes_hello_world.js"); assert_eq!(pkg.main, "scopes_hello_world.js");
let actual_files: HashSet<String> = pkg.files.into_iter().collect(); let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> = [ let expected_files: HashSet<String> = ["scopes_hello_world_bg.wasm", "scopes_hello_world.d.ts"]
"scopes_hello_world_bg.wasm", .iter()
"scopes_hello_world.d.ts",
].iter()
.map(|&s| String::from(s)) .map(|&s| String::from(s))
.collect(); .collect();
assert_eq!(actual_files, expected_files); assert_eq!(actual_files, expected_files);
@ -167,11 +164,10 @@ fn it_creates_a_package_json_with_correct_keys_when_types_are_skipped() {
assert_eq!(pkg.main, "wasm_pack.js"); assert_eq!(pkg.main, "wasm_pack.js");
let actual_files: HashSet<String> = pkg.files.into_iter().collect(); let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> = let expected_files: HashSet<String> = ["wasm_pack_bg.wasm"]
["wasm_pack_bg.wasm"] .iter()
.iter() .map(|&s| String::from(s))
.map(|&s| String::from(s)) .collect();
.collect();
assert_eq!(actual_files, expected_files); assert_eq!(actual_files, expected_files);
} }

Loading…
Cancel
Save