Repository: ashleygwilliams/wasm-pack (rust)

Issue:
don't rename the js file
Hello! I was following the tutorial for wasm-pack and got to this step: https://rust-lang-nursery.github.io/rust-wasm/wasm-pack/package-code.html

Compiling took a while and then printed this:

```
wasm-pack -v init --scope thallada
  [1/7] Adding WASM target...
  [2/7] Compiling to WASM...
  [3/7] Creating a pkg directory...
  [4/7] Writing a package.json...
| [5/7] Copying over your README...
| :-) [WARN]: origin crate has no README
  [6/7] Installing WASM-bindgen...
  [7/7] Running WASM-bindgen...
:-) Done in 1 minute
:-) Your WASM pkg is ready to publish at ./pkg
```

But, if I look at the `./pkg` directory, there's only a `package.json` file:

```
$ ls pkg/
package.json
```

Do you know what might have gone wrong?

```
$ npm --version
v9.11.1

$ npm --version
5.6.0

$ rustup show
Default host: x86_64-unknown-linux-gnu

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)

installed targets for active toolchain
--------------------------------------

asmjs-unknown-emscripten
wasm32-unknown-emscripten
wasm32-unknown-unknown
x86_64-unknown-linux-gnu

active toolchain
----------------

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.27.0-nightly (ac3c2288f 2018-04-18)
```

Pull request:
fix(bindgen): don't rename to index
fixes #102 

Patch:
diff --git a/src/bindgen.rs b/src/bindgen.rs
index 3b587b1..a640c0e 100644
--- a/src/bindgen.rs
+++ b/src/bindgen.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(())
     }
 }
diff --git a/src/manifest.rs b/src/manifest.rs
index 9f60435..9ea770f 100644
--- a/src/manifest.rs
+++ b/src/manifest.rs
@@ -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,
         }
     }
 }


Test patch:
diff --git a/tests/manifest/main.rs b/tests/manifest/main.rs
index 6b4ca9e..813087d 100644
--- a/tests/manifest/main.rs
+++ b/tests/manifest/main.rs
@@ -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]