Skip to content

Commit

Permalink
fix(bindgen): don't rename to index
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleygwilliams committed Apr 23, 2018
1 parent c779c74 commit 7da29b2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/bindgen.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use console::style;
use emoji;
use failure::Error;
use std::fs;
use std::process::Command;
use PBAR;

Expand Down Expand Up @@ -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(())
}
}
3 changes: 2 additions & 1 deletion src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -69,7 +70,7 @@ impl CargoManifest {
url: repo_url,
}),
files: vec![wasm_file],
main: "index.js".to_string(),
main: js_file,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/manifest/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 7da29b2

Please sign in to comment.