1
0
mirror of https://github.com/jht5945/buildj.git synced 2025-12-29 18:30:05 +08:00

feat: exit with non 0, when fails

This commit is contained in:
2020-12-26 22:21:17 +08:00
parent 6fa4b60bc4
commit bd52eb6042
8 changed files with 609 additions and 606 deletions

1160
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "buildj" name = "buildj"
version = "0.1.3" version = "0.1.4"
authors = ["Hatter Jiang <jht5945@gmail.com>"] authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018" edition = "2018"
@@ -12,4 +12,4 @@ urlencoding = "1.1.1"
dirs = "3.0.1" dirs = "3.0.1"
rust-crypto = "0.2.36" rust-crypto = "0.2.36"
lazy_static = "1.4.0" lazy_static = "1.4.0"
rust_util = "0.6.15" rust_util = "0.6.22"

View File

@@ -1,6 +1,6 @@
use std::{collections::HashMap, env, fs, str, path::Path, process::Command}; use std::{collections::HashMap, env, fs, str, path::Path, process::Command};
use rust_util::util_os; use rust_util::util_os;
use crate::{ local_util, tool, misc::{ VERBOSE } }; use crate::{local_util, tool, misc::VERBOSE};
const PATH: &str = "PATH"; const PATH: &str = "PATH";
const JAVA_HOME: &str = "JAVA_HOME"; const JAVA_HOME: &str = "JAVA_HOME";

View File

@@ -2,14 +2,12 @@
extern crate json; extern crate json;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
extern crate term;
extern crate dirs;
extern crate crypto;
extern crate urlencoding;
#[macro_use] #[macro_use]
extern crate rust_util; extern crate rust_util;
use std::{ collections::HashMap, fs, process::Command }; use std::fs;
use std::collections::HashMap;
use std::process::{self, Command};
pub mod jdk; pub mod jdk;
pub mod local_util; pub mod local_util;
@@ -46,9 +44,9 @@ fn do_with_buildin_arg_java(first_arg: &str, args: &[String]) {
if args.len() > 2 { if args.len() > 2 {
cmd.args(&args[2..]); cmd.args(&args[2..]);
} }
run_command_and_wait(&mut cmd).unwrap_or_else(|err| { if let Err(err) = run_command_and_wait(&mut cmd) {
failure!("Exec java failed: {}", err); failure!("Exec java failed: {}", err);
}); }
}, },
}; };
} }
@@ -127,9 +125,9 @@ fn do_with_buildin_arg_builder(first_arg: &str, args: &[String], builder_name: &
for arg in args.iter().skip(from_index) { for arg in args.iter().skip(from_index) {
cmd.arg(&arg); cmd.arg(&arg);
} }
run_command_and_wait(&mut cmd).unwrap_or_else(|err| { if let Err(err) = run_command_and_wait(&mut cmd) {
failure!("Run build command failed: {}", err); failure!("Run build command failed: {}", err);
}); }
} }
fn do_with_buildin_arg_ddd(first_arg: &str, args: &[String]) { fn do_with_buildin_arg_ddd(first_arg: &str, args: &[String]) {
@@ -160,9 +158,9 @@ fn do_with_buildin_arg_ddd(first_arg: &str, args: &[String]) {
if *VERBOSE { if *VERBOSE {
debugging!("Running cmd: {}, args: {:?}", &cmd_name, cmd_args); debugging!("Running cmd: {}, args: {:?}", &cmd_name, cmd_args);
} }
run_command_and_wait(&mut cmd).unwrap_or_else(|err| { if let Err(err) = run_command_and_wait(&mut cmd) {
failure!("Run xRun command failed: {}", err); failure!("Run xRun command failed: {}", err);
}); }
} }
fn do_with_buildin_args(args: &[String]) { fn do_with_buildin_args(args: &[String]) {
@@ -376,7 +374,14 @@ fn main() {
} }
debugging!("-----END ENVIRONMENT VARIABLES-----"); debugging!("-----END ENVIRONMENT VARIABLES-----");
} }
run_command_and_wait(&mut cmd).unwrap_or_else(|err| { let exit_status = run_command_and_wait(&mut cmd).unwrap_or_else(|err| {
failure!("Run build command failed: {}", err); failure!("Run build command failed: {}", err);
process::exit(-1);
}); });
if !exit_status.success() {
if let Some(exit_code) = exit_status.code() {
process::exit(exit_code);
}
}
} }