1
0
mirror of https://github.com/jht5945/buildj.git synced 2025-12-28 01:31:35 +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

View File

@@ -1,5 +1,5 @@
use std::{ fs, path::Path };
use rust_util::{ XResult, new_box_ioerror };
use std::{fs, path::Path};
use rust_util::{XResult, new_box_ioerror};
use crate::http::get_url_content;
use crate::misc::VERBOSE;

View File

@@ -1,5 +1,5 @@
use std::fs::File;
use rust_util::{ XResult, util_io };
use rust_util::{XResult, util_io};
use crate::misc::VERBOSE;

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 crate::{ local_util, tool, misc::{ VERBOSE } };
use crate::{local_util, tool, misc::VERBOSE};
const PATH: &str = "PATH";
const JAVA_HOME: &str = "JAVA_HOME";

View File

@@ -1,6 +1,6 @@
use std::{ env, fs::{ self, File }, io::{ Read, ErrorKind }, path::Path, process::Command };
use rust_util::{ XResult, new_box_ioerror, util_io::{ self, DEFAULT_BUF_SIZE, PrintStatusContext } };
use crypto::{ digest::Digest, md5::Md5, sha1::Sha1, sha2::{ Sha256, Sha512 } };
use std::{env, fs::{self, File}, io::{Read, ErrorKind}, path::Path, process::Command};
use rust_util::{XResult, new_box_ioerror, util_io::{self, DEFAULT_BUF_SIZE, PrintStatusContext}};
use crypto::{digest::Digest, md5::Md5, sha1::Sha1, sha2::{Sha256, Sha512}};
pub fn get_args_as_vec() -> Vec<String> {
env::args().collect::<Vec<String>>()

View File

@@ -2,14 +2,12 @@
extern crate json;
#[macro_use]
extern crate lazy_static;
extern crate term;
extern crate dirs;
extern crate crypto;
extern crate urlencoding;
#[macro_use]
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 local_util;
@@ -46,9 +44,9 @@ fn do_with_buildin_arg_java(first_arg: &str, args: &[String]) {
if args.len() > 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);
});
}
},
};
}
@@ -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) {
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);
});
}
}
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 {
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);
});
}
}
fn do_with_buildin_args(args: &[String]) {
@@ -376,7 +374,14 @@ fn main() {
}
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);
process::exit(-1);
});
if !exit_status.success() {
if let Some(exit_code) = exit_status.code() {
process::exit(exit_code);
}
}
}

View File

@@ -1,6 +1,6 @@
use std::{ fs::{ self, File }, path::Path };
use rust_util::{ XResult, new_box_ioerror, util_os };
use crate::{ http, local_util, misc::{ AUTH_TOKEN, VERBOSE, NOAUTH } };
use std::{fs::{self, File}, path::Path};
use rust_util::{ XResult, new_box_ioerror, util_os};
use crate::{http, local_util, misc::{AUTH_TOKEN, VERBOSE, NOAUTH}};
const M2_HOME: &str = "M2_HOME";
const MAVEN_HOME: &str = "MAVEN_HOME";