fix(bindgen): don't rename to index

master
Ashley Williams 7 years ago
parent c779c74c04
commit 7da29b27b4
  1. 4
      src/bindgen.rs
  2. 3
      src/manifest.rs
  3. 2
      tests/manifest/main.rs

@ -1,7 +1,6 @@
use console::style;
use emoji;
use failure::Error;
use std::fs;
use std::process::Command;
use PBAR;
@ -51,9 +50,6 @@ pub fn wasm_bindgen_build(path: &str, name: &str) -> Result<(), Error> {
PBAR.error("wasm-bindgen failed to execute properly");
bail!(format!("Details:\n{}", s));
} else {
let js_file = format!("{}/pkg/{}.js", path, binary_name);
let index_file = format!("{}/pkg/index.js", path);
fs::rename(&js_file, &index_file)?;
Ok(())
}
}

@ -55,6 +55,7 @@ impl CargoManifest {
fn into_npm(mut self, scope: Option<String>) -> NpmPackage {
let filename = self.package.name.replace("-", "_");
let wasm_file = format!("{}_bg.wasm", filename);
let js_file = format!("{}.js", filename);
if let Some(s) = scope {
self.package.name = format!("@{}/{}", s, self.package.name);
}
@ -69,7 +70,7 @@ impl CargoManifest {
url: repo_url,
}),
files: vec![wasm_file],
main: "index.js".to_string(),
main: js_file,
}
}
}

@ -41,7 +41,7 @@ fn it_creates_a_package_json_default_path() {
"https://github.com/ashleygwilliams/wasm-pack.git"
);
assert_eq!(pkg.files, ["wasm_pack_bg.wasm"]);
assert_eq!(pkg.main, "index.js");
assert_eq!(pkg.main, "wasm_pack.js");
}
#[test]

Loading…
Cancel
Save