diff --git a/Cargo.lock b/Cargo.lock index 77ac158..5d89ca7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,6 +73,20 @@ dependencies = [ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "binary-install" +version = "0.0.1" +dependencies = [ + "curl 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", + "zip 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bitflags" version = "1.0.4" @@ -1227,6 +1241,7 @@ name = "wasm-pack" version = "0.5.1" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "binary-install 0.0.1", "cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "console 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1251,24 +1266,9 @@ dependencies = [ "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-pack-binary-install 0.1.0", "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "wasm-pack-binary-install" -version = "0.1.0" -dependencies = [ - "curl 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "zip 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "which" version = "2.0.1" diff --git a/Cargo.toml b/Cargo.toml index 69b21b3..e2daa4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ siphasher = "0.2.3" structopt = "0.2" toml = "0.4" which = "2.0.0" -wasm-pack-binary-install = { version = "0.1.0", path = "./binary-install" } +binary-install = { version = "0.0.1", path = "./binary-install" } walkdir = "2" [dev-dependencies] diff --git a/binary-install/Cargo.toml b/binary-install/Cargo.toml index 76d71b1..a14b484 100644 --- a/binary-install/Cargo.toml +++ b/binary-install/Cargo.toml @@ -1,6 +1,12 @@ [package] -name = "wasm-pack-binary-install" -version = "0.1.0" +name = "binary-install" +description = "install a binary from a path to a global cache" +authors = ["The wasm-pack team"] +repository = "https://github.com/rustwasm/wasm-pack/tree/master/binary-install" +license = "MIT/Apache-2.0" +version = "0.0.1" +documentation = "https://docs.rs/binary-install" +readme = "./README.md" [dependencies] curl = "0.4.13" diff --git a/binary-install/README.md b/binary-install/README.md new file mode 100644 index 0000000..a79d5df --- /dev/null +++ b/binary-install/README.md @@ -0,0 +1,2 @@ +# `binary-install` +> install a binary from a path to a global cache diff --git a/binary-install/src/lib.rs b/binary-install/src/lib.rs index dcef39f..c2dcf2c 100644 --- a/binary-install/src/lib.rs +++ b/binary-install/src/lib.rs @@ -36,13 +36,15 @@ impl Cache { /// /// This function may return an error if a cache directory cannot be /// determined. - pub fn new() -> Result { + pub fn new(name: &str) -> Result { + let cache_name = format!(".{}", name); let destination = dirs::cache_dir() - .map(|p| p.join("wasm-pack")) + .map(|p| p.join(&cache_name)) .or_else(|| { let home = dirs::home_dir()?; - Some(home.join(".wasm-pack")) - }).ok_or_else(|| format_err!("couldn't find your home directory, is $HOME not set?"))?; + Some(home.join(&cache_name)) + }) + .ok_or_else(|| format_err!("couldn't find your home directory, is $HOME not set?"))?; Ok(Cache::at(&destination)) } diff --git a/src/bindgen.rs b/src/bindgen.rs index c2ad7b2..5263a75 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -1,5 +1,6 @@ //! Functionality related to installing and running `wasm-bindgen`. +use binary_install::{Cache, Download}; use child; use command::build::BuildProfile; use emoji; @@ -12,7 +13,6 @@ use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; use target; -use wasm_pack_binary_install::{Cache, Download}; use which::which; use PBAR; diff --git a/src/command/build.rs b/src/command/build.rs index 29b1eaf..c6bad24 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -1,5 +1,6 @@ //! Implementation of the `wasm-pack build` command. +use binary_install::{Cache, Download}; use bindgen; use build; use command::utils::{create_pkg_dir, set_crate_path}; @@ -15,7 +16,6 @@ use readme; use std::path::PathBuf; use std::str::FromStr; use std::time::Instant; -use wasm_pack_binary_install::{Cache, Download}; use PBAR; /// Everything required to configure and run the `wasm-pack init` command. @@ -180,7 +180,7 @@ impl Build { mode: build_opts.mode, out_dir, bindgen: None, - cache: Cache::new()?, + cache: Cache::new("wasm_pack")?, extra_options: build_opts.extra_options, }) } diff --git a/src/command/test.rs b/src/command/test.rs index 99c95e2..71f3f21 100644 --- a/src/command/test.rs +++ b/src/command/test.rs @@ -1,6 +1,7 @@ //! Implementation of the `wasm-pack test` command. use super::build::BuildMode; +use binary_install::Cache; use bindgen; use build; use command::utils::set_crate_path; @@ -15,7 +16,6 @@ use progressbar::Step; use std::path::PathBuf; use std::time::Instant; use test::{self, webdriver}; -use wasm_pack_binary_install::Cache; use PBAR; #[derive(Debug, Default, StructOpt)] @@ -132,7 +132,7 @@ impl Test { } Ok(Test { - cache: Cache::new()?, + cache: Cache::new("wasm_pack")?, crate_path, crate_data, node, diff --git a/src/lib.rs b/src/lib.rs index 0f0e4a0..164988e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,11 +20,11 @@ extern crate serde_ignored; extern crate serde_json; #[macro_use] extern crate structopt; +extern crate binary_install; extern crate dialoguer; extern crate log; extern crate toml; extern crate walkdir; -extern crate wasm_pack_binary_install; pub mod bindgen; pub mod build; diff --git a/src/test/webdriver.rs b/src/test/webdriver.rs index 9709c40..9fc3c56 100644 --- a/src/test/webdriver.rs +++ b/src/test/webdriver.rs @@ -1,10 +1,10 @@ //! Getting WebDriver client binaries. +use binary_install::Cache; use command::build::BuildMode; use failure; use std::path::PathBuf; use target; -use wasm_pack_binary_install::Cache; /// Get the path to an existing `chromedriver`, or install it if no existing /// binary is found. diff --git a/tests/all/bindgen.rs b/tests/all/bindgen.rs index e1077c5..e935b8a 100644 --- a/tests/all/bindgen.rs +++ b/tests/all/bindgen.rs @@ -1,6 +1,6 @@ +use binary_install::Cache; use tempfile; use wasm_pack::bindgen; -use wasm_pack_binary_install::Cache; #[test] #[cfg(any( diff --git a/tests/all/main.rs b/tests/all/main.rs index 61875e0..06806cd 100644 --- a/tests/all/main.rs +++ b/tests/all/main.rs @@ -3,11 +3,11 @@ extern crate failure; extern crate lazy_static; #[macro_use] extern crate serde_derive; +extern crate binary_install; extern crate serde_json; extern crate structopt; extern crate tempfile; extern crate wasm_pack; -extern crate wasm_pack_binary_install; mod bindgen; mod build; diff --git a/tests/all/utils/fixture.rs b/tests/all/utils/fixture.rs index 2ed126e..f98b2e2 100644 --- a/tests/all/utils/fixture.rs +++ b/tests/all/utils/fixture.rs @@ -1,3 +1,4 @@ +use binary_install::Cache; use std::env; use std::fs; use std::mem::ManuallyDrop; @@ -7,7 +8,6 @@ use std::sync::{MutexGuard, Once, ONCE_INIT}; use std::thread; use tempfile::TempDir; use wasm_pack; -use wasm_pack_binary_install::Cache; /// A test fixture in a temporary directory. pub struct Fixture { diff --git a/tests/all/webdriver.rs b/tests/all/webdriver.rs index c0bbaa5..d5e8cf6 100644 --- a/tests/all/webdriver.rs +++ b/tests/all/webdriver.rs @@ -1,6 +1,6 @@ +use binary_install::Cache; use utils::fixture; use wasm_pack::test::webdriver; -use wasm_pack_binary_install::Cache; #[test] #[cfg(any(