Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
Removed unnecessary macro and added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
daubaris committed Mar 26, 2019
1 parent e918fdd commit b30b72b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
22 changes: 2 additions & 20 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,8 @@ pub fn check_wasm_pack_versions() -> Result<(String, String), Error> {
}

fn wasm_pack_local_version() -> Option<String> {
macro_rules! otry {
($e:expr) => {
match $e {
Some(e) => e,
None => return None,
}
};
}

let output = otry!(Command::new("wasm-pack").arg("--version").output().ok());
let version = otry!(str::from_utf8(&output.stdout).ok());
let mut pieces = version.split(' ');
if pieces.next() != Some("wasm-pack") {
return None;
}
otry!(pieces.next())
.to_string()
.trim()
.parse::<String>()
.ok()
let output = env!("CARGO_PKG_VERSION");
Some(output.to_string())
}

/// Get rustc's sysroot as a PathBuf
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ fn run() -> Result<(), failure::Error> {
run_wasm_pack(args.cmd)?;

if let Ok(update_available) = update_available.try_recv() {
println!("There's a newer version of wasm-pack available, the new version is: {}, you are using: {}", update_available.1, update_available.0);
println!("There's a newer version of wasm-pack available, the new version is: {}, you are using: {}. \
To update, navigate to: https://rustwasm.github.io/wasm-pack/installer/", update_available.1, update_available.0);
}

Ok(())
Expand Down
7 changes: 5 additions & 2 deletions src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl Crate {
}

fn return_api_call_result(current_time: DateTime<offset::Local>) -> Option<String> {
Crate::call_for_wasm_pack_version().and_then(|v| {
Crate::return_latest_wasm_pack_version().and_then(|v| {
Crate::override_stamp_file(current_time, &v);
Some(v)
})
Expand All @@ -188,6 +188,7 @@ impl Crate {
}
}

/// Return stamp file where metadata is stored.
fn return_wasm_pack_file() -> Option<String> {
if let Ok(path) = which::which("wasm-pack") {
if let Ok(file) = fs::read_to_string(path.with_extension("stamp")) {
Expand All @@ -197,13 +198,15 @@ impl Crate {
None
}

fn call_for_wasm_pack_version() -> Option<String> {
/// Returns wasm-pack latest version (if it's received) by executing check_wasm_pack_latest_version function.
fn return_latest_wasm_pack_version() -> Option<String> {
if let Ok(crt) = Crate::check_wasm_pack_latest_version() {
return Some(crt.crt.max_version);
}
None
}

/// Read the stamp file and return value assigned to a certain key.
fn return_stamp_file_value(file: &String, word: &str) -> Option<String> {
let created = file
.lines()
Expand Down

0 comments on commit b30b72b

Please sign in to comment.