fix runts exit code
This commit is contained in:
@@ -2,8 +2,8 @@ use crate::resolver::resolve_file;
|
||||
use crate::{verify, RunScriptArgs};
|
||||
use rust_util::util_cmd;
|
||||
use rust_util::util_env::is_env_on;
|
||||
use std::fs;
|
||||
use std::process::Command;
|
||||
use std::{fs, process};
|
||||
|
||||
const RUNTIME_DENO: &str = "--runtime-deno";
|
||||
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)
|
||||
.unwrap_or_else(|e| failure_and_exit!("Failed to resolve script: {}", e));
|
||||
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");
|
||||
// #!/usr/bin/env runts -- --allow-env
|
||||
@@ -63,7 +66,8 @@ pub fn do_run_script(args: &RunScriptArgs) {
|
||||
if arg == RUNTIME_DENO || arg == RUNTIME_BUN {
|
||||
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);
|
||||
} else {
|
||||
cmd.arg(arg);
|
||||
@@ -71,8 +75,9 @@ pub fn do_run_script(args: &RunScriptArgs) {
|
||||
}
|
||||
|
||||
debugging!("Run command: {cmd:?}");
|
||||
if let Err(e) = util_cmd::run_command_and_wait(&mut cmd) {
|
||||
failure_and_exit!("Run deno: {script_file} failed: {e}");
|
||||
match util_cmd::run_command_and_wait(&mut cmd) {
|
||||
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