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:
1160
Cargo.lock
generated
1160
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "buildj"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
@@ -12,4 +12,4 @@ urlencoding = "1.1.1"
|
||||
dirs = "3.0.1"
|
||||
rust-crypto = "0.2.36"
|
||||
lazy_static = "1.4.0"
|
||||
rust_util = "0.6.15"
|
||||
rust_util = "0.6.22"
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::fs::File;
|
||||
use rust_util::{ XResult, util_io };
|
||||
use rust_util::{XResult, util_io};
|
||||
|
||||
use crate::misc::VERBOSE;
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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>>()
|
||||
|
||||
29
src/main.rs
29
src/main.rs
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user