From f66d321ba9bf08d327bccc3e2f2945c0c3b53f69 Mon Sep 17 00:00:00 2001 From: Brennon Loveless <brennon.loveless@gmail.com> Date: Wed, 6 Jan 2021 19:54:06 -0500 Subject: [PATCH 1/2] First look in the local path for the wasm-opt binary. Use whatever binary is found and assume it works --- src/wasm_opt.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wasm_opt.rs b/src/wasm_opt.rs index 19f33c3..fb8b4bb 100644 --- a/src/wasm_opt.rs +++ b/src/wasm_opt.rs @@ -3,7 +3,7 @@ use crate::child; use crate::install::{self, Tool}; use crate::PBAR; -use binary_install::Cache; +use binary_install::{Cache, Download}; use std::path::Path; use std::process::Command; @@ -58,6 +58,16 @@ pub fn find_wasm_opt( cache: &Cache, install_permitted: bool, ) -> Result<install::Status, failure::Error> { + // First attempt to look up in PATH. If found assume it works. + if let Ok(path) = which::which("wasm-opt") { + PBAR.info(&format!("found wasm-opt at {:?}", path)); + + match path.as_path().parent() { + Some(path) => return Ok(install::Status::Found(Download::at(path))), + _ => {} + } + } + let version = "version_78"; Ok(install::download_prebuilt( &install::Tool::WasmOpt, From fee0938c3417dbcd5d72544a8c1981d761590042 Mon Sep 17 00:00:00 2001 From: Brennon Loveless <brennon.loveless@gmail.com> Date: Wed, 6 Jan 2021 20:05:50 -0500 Subject: [PATCH 2/2] Feel better to explictly declare the arms instead of using a match all --- src/wasm_opt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wasm_opt.rs b/src/wasm_opt.rs index fb8b4bb..d3ad4c6 100644 --- a/src/wasm_opt.rs +++ b/src/wasm_opt.rs @@ -64,7 +64,7 @@ pub fn find_wasm_opt( match path.as_path().parent() { Some(path) => return Ok(install::Status::Found(Download::at(path))), - _ => {} + None => {} } }