Merge pull request #5 from ashleygwilliams/pkg-dir

feat(pkg): do it in a dir
master
ashley williams 7 years ago committed by GitHub
commit cf76d3cde0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .gitignore
  2. 9
      src/lib.rs
  3. 2
      tests/wasm-pack.rs

2
.gitignore vendored

@ -1,4 +1,4 @@
/target
**/*.rs.bk
package.json
/pkg

@ -4,6 +4,7 @@ extern crate serde_derive;
extern crate serde_json;
extern crate toml;
use std::fs;
use std::fs::File;
use std::io::prelude::*;
@ -46,8 +47,14 @@ impl CargoManifest {
}
}
fn create_pkg_dir() -> Result<(), Error> {
fs::create_dir_all("./pkg")?;
Ok(())
}
pub fn write_package_json() -> Result<(), Error> {
let mut pkg_file = File::create("package.json")?;
create_pkg_dir()?;
let mut pkg_file = File::create("./pkg/package.json")?;
let crate_data = read_cargo_toml()?;
let npm_data = crate_data.into_npm();
let npm_json = serde_json::to_string(&npm_data)?;

@ -5,5 +5,5 @@ use std::fs;
#[test]
fn it_creates_a_package_json() {
assert!(wasm_pack::write_package_json().is_ok());
assert!(fs::metadata("./package.json").is_ok());
assert!(fs::metadata("./pkg/package.json").is_ok());
}

Loading…
Cancel
Save