fix runts exit code
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1221,7 +1221,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "runrs"
|
name = "runrs"
|
||||||
version = "1.1.9"
|
version = "1.1.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argh",
|
"argh",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "runrs"
|
name = "runrs"
|
||||||
version = "1.1.9"
|
version = "1.1.10"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
description = "A Tool for Run Rust/TypeScript Scripts"
|
description = "A Tool for Run Rust/TypeScript Scripts"
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use crate::resolver::resolve_file;
|
|||||||
use crate::{verify, RunScriptArgs};
|
use crate::{verify, RunScriptArgs};
|
||||||
use rust_util::util_cmd;
|
use rust_util::util_cmd;
|
||||||
use rust_util::util_env::is_env_on;
|
use rust_util::util_env::is_env_on;
|
||||||
use std::fs;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
use std::{fs, process};
|
||||||
|
|
||||||
const RUNTIME_DENO: &str = "--runtime-deno";
|
const RUNTIME_DENO: &str = "--runtime-deno";
|
||||||
const RUNTIME_BUN: &str = "--runtime-bun";
|
const RUNTIME_BUN: &str = "--runtime-bun";
|
||||||
@@ -29,7 +29,10 @@ pub fn do_run_script(args: &RunScriptArgs) {
|
|||||||
let script_file = resolve_file(raw_script_file, args.force_update)
|
let script_file = resolve_file(raw_script_file, args.force_update)
|
||||||
.unwrap_or_else(|e| failure_and_exit!("Failed to resolve script: {}", e));
|
.unwrap_or_else(|e| failure_and_exit!("Failed to resolve script: {}", e));
|
||||||
let script_file = &script_file;
|
let script_file = &script_file;
|
||||||
verify::verify_script(script_file, is_env_on("RUNTS_SKIP_VERIFY") || is_env_on("RSV"));
|
verify::verify_script(
|
||||||
|
script_file,
|
||||||
|
is_env_on("RUNTS_SKIP_VERIFY") || is_env_on("RSV"),
|
||||||
|
);
|
||||||
|
|
||||||
let mut cmd = Command::new("/usr/bin/env");
|
let mut cmd = Command::new("/usr/bin/env");
|
||||||
// #!/usr/bin/env runts -- --allow-env
|
// #!/usr/bin/env runts -- --allow-env
|
||||||
@@ -63,7 +66,8 @@ pub fn do_run_script(args: &RunScriptArgs) {
|
|||||||
if arg == RUNTIME_DENO || arg == RUNTIME_BUN {
|
if arg == RUNTIME_DENO || arg == RUNTIME_BUN {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if arg == raw_script_file { // replace remote file with local file
|
if arg == raw_script_file {
|
||||||
|
// replace remote file with local file
|
||||||
cmd.arg(script_file);
|
cmd.arg(script_file);
|
||||||
} else {
|
} else {
|
||||||
cmd.arg(arg);
|
cmd.arg(arg);
|
||||||
@@ -71,8 +75,9 @@ pub fn do_run_script(args: &RunScriptArgs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
debugging!("Run command: {cmd:?}");
|
debugging!("Run command: {cmd:?}");
|
||||||
if let Err(e) = util_cmd::run_command_and_wait(&mut cmd) {
|
match util_cmd::run_command_and_wait(&mut cmd) {
|
||||||
failure_and_exit!("Run deno: {script_file} failed: {e}");
|
Ok(exit_status) => process::exit(exit_status.code().unwrap_or(0)),
|
||||||
|
Err(e) => failure_and_exit!("Run deno: {script_file} failed: {e}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user