Skip to content

Commit

Permalink
fix: check env
Browse files Browse the repository at this point in the history
  • Loading branch information
lencx committed May 19, 2022
1 parent b8ae720 commit 719d28f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rsw"
version = "0.7.8"
version = "0.7.9"
description = "wasm-pack based build tool"
edition = "2021"
authors = ["lencx <cxin1314@gmail.com>"]
Expand All @@ -23,6 +23,6 @@ regex = "1.5.4"
serde = "1.0.133"
serde_derive = "1.0.133"
toml = "0.5.8"
which = "4.2.4"
which = "4.2.5"
ignore = "0.4.18"
tokio = { version = "1.18.0", features = ["macros", "rt-multi-thread"] }
4 changes: 1 addition & 3 deletions npm/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const error = msg => {
process.exit(1);
};

// const { version, name, repository } = require("./package.json");
const { name, repository } = require("./package.json");
const version = '0.7.8';
const { rsw_version: version, name, repository } = require("./package.json");

const supportedPlatforms = [
{
Expand Down
3 changes: 2 additions & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@rsw/cli",
"version": "0.7.9",
"version": "0.7.10",
"rsw_version": "0.7.9",
"description": "🦞 wasm-pack based build tool",
"main": "binary.js",
"author": "lencx <cxin1314@gmail.com>",
Expand Down
20 changes: 18 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,29 @@ pub fn check_env_cmd(program: &str) -> bool {
let result = which(program);
match result {
Err(e) => {
eprint!("{}\n", e);
false
if is_program_in_path(program) {
true
} else {
eprint!("{}\n", e);
false
}
}
_ => true,
}
}

pub fn is_program_in_path(program: &str) -> bool {
if let Ok(path) = env::var("PATH") {
for p in path.split(":") {
let p_str = format!("{}/{}", p, program);
if fs::metadata(p_str).is_ok() {
return true;
}
}
}
false
}

// get fields from `Cargo.toml`
pub fn get_crate_metadata(name: &str, root: PathBuf) -> Value {
let crate_root = root.join("Cargo.toml");
Expand Down

0 comments on commit 719d28f

Please sign in to comment.