diff --git a/Cargo.lock b/Cargo.lock index 5a2b510..92e41b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,7 +128,7 @@ dependencies = [ [[package]] name = "runrs" -version = "0.1.10" +version = "0.1.11" dependencies = [ "rust_util", "sha256", diff --git a/Cargo.toml b/Cargo.toml index a0f14fa..9f8e8b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runrs" -version = "0.1.10" +version = "0.1.11" edition = "2018" license = "MIT/Apache-2.0" description = "Run Rust Scripts" diff --git a/README.md b/README.md index 5cc2251..7b00ca1 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,14 @@ cargo install --git https://git.hatter.ink/hatter/runrs runrs Environment variables -| Env Key | Env Value | -|---------------|----------------------------------------------------------------| -| `HOME` | User home, default by OS system | +| Env Key | Env Value | +|---------------|---------------------------------------------------------------| +| `HOME` | User home, default by OS system | | `RUNRS_SKIP_CACHE` | Skip compiled cached file , turn on `true`, `yes`, `on` or `1` | -| `RUNRS_SILENT_BUILD` | Build new binary in silent mode | -| `RUNRS_RUST_SCRIPT` | `rust_script` command line bin file | -| `RUNRS_MAX_SCRIPT_LEN` | Max script length | +| `RUNRS_REBUILD` | Force rebuild | +| `RUNRS_SILENT_BUILD` | Build new binary in silent mode | +| `RUNRS_RUST_SCRIPT` | `rust_script` command line bin file | +| `RUNRS_MAX_SCRIPT_LEN` | Max script length |
diff --git a/src/main.rs b/src/main.rs index 79782af..7e4453f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,9 +36,10 @@ fn main() { fn build_script_command(rust_script: PathBuf, script_file: &str, script_sha256: &str, cache_script_bin_name: &str) -> Command { let skip_cache = is_env_on("RUNRS_SKIP_CACHE"); + let rebuild = is_env_on("RUNRS_REBUILD"); let cache_script_bin_name_exists = fs::metadata(&cache_script_bin_name).is_ok(); debugging!("Bin name: {} {}exists", cache_script_bin_name, iff!(cache_script_bin_name_exists, "", "not ")); - if !skip_cache && cache_script_bin_name_exists { + if !rebuild && !skip_cache && cache_script_bin_name_exists { Command::new(&cache_script_bin_name) } else { let mut cmd = Command::new(rust_script); @@ -46,6 +47,9 @@ fn build_script_command(rust_script: PathBuf, script_file: &str, script_sha256: information!("Cached binary not exists, RUNRS_SILENT_BUILD=1 turn off"); cmd.arg("--cargo-output"); } + if rebuild { + cmd.arg("--force"); + } cmd.args(&["--bin-name", &script_sha256, script_file]); cmd }