feat: v0.1.6 write *.src file
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -128,7 +128,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "runrs"
|
||||
version = "0.1.5"
|
||||
version = "0.1.6"
|
||||
dependencies = [
|
||||
"rust_util",
|
||||
"sha256",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "runrs"
|
||||
version = "0.1.5"
|
||||
version = "0.1.6"
|
||||
edition = "2018"
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "Run Rust Scripts"
|
||||
|
||||
21
src/main.rs
21
src/main.rs
@@ -60,16 +60,8 @@ runrs <script.rs> [arguments]
|
||||
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 "));
|
||||
let mut run_script_cmd = if cache_script_bin_name_exists {
|
||||
Command::new(cache_script_bin_name)
|
||||
Command::new(&cache_script_bin_name)
|
||||
} else {
|
||||
if let Ok(Some(canonicalized_script_file)) = PathBuf::from(script_file)
|
||||
.canonicalize().map(|f| f.to_str().map(|f| f.to_string())) {
|
||||
let cache_script_bin_name_src = format!("{}.src", cache_script_bin_name);
|
||||
if let Ok(_) = fs::write(&cache_script_bin_name_src, &format!("{}\n", canonicalized_script_file)) {
|
||||
debugging!("Write {} to {}", canonicalized_script_file, cache_script_bin_name_src);
|
||||
}
|
||||
}
|
||||
|
||||
let mut cmd = Command::new(rust_script);
|
||||
if util_msg::is_logger_level_enabled(MessageType::DEBUG) {
|
||||
cmd.arg("--cargo-output");
|
||||
@@ -83,6 +75,15 @@ runrs <script.rs> [arguments]
|
||||
debugging!("Run command: {:?}", run_script_cmd);
|
||||
match rust_util::util_cmd::run_command_and_wait(&mut run_script_cmd) {
|
||||
Err(e) => failure_and_exit!("Run rust-script failed: {}", e),
|
||||
Ok(exit_status) => std::process::exit(exit_status.code().unwrap_or_else(|| 0)),
|
||||
Ok(exit_status) => {
|
||||
if let Ok(Some(canonicalized_script_file)) = PathBuf::from(script_file)
|
||||
.canonicalize().map(|f| f.to_str().map(|f| f.to_string())) {
|
||||
let cache_script_bin_name_src = format!("{}.src", cache_script_bin_name);
|
||||
if let Ok(_) = fs::write(&cache_script_bin_name_src, &format!("{}\n", canonicalized_script_file)) {
|
||||
debugging!("Write {} to {}", canonicalized_script_file, cache_script_bin_name_src);
|
||||
}
|
||||
}
|
||||
std::process::exit(exit_status.code().unwrap_or_else(|| 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user