Exit status are considered as error
This commit is contained in:
parent
206c8c7bf8
commit
258d426ffd
@ -28,7 +28,7 @@ pub struct System {
|
||||
// exclusive_with : List
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
struct Cmd {
|
||||
exe: String,
|
||||
params: Vec<String>,
|
||||
@ -36,7 +36,7 @@ struct Cmd {
|
||||
env: HashMap<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub(crate) struct ActualCmd {
|
||||
exe: String,
|
||||
params: Vec<String>,
|
||||
@ -143,8 +143,16 @@ impl System {
|
||||
pub fn fetch(&self, opt: &Opt) -> Result<()> {
|
||||
if let Some(fetch) = &self.fetch {
|
||||
let cmd = fetch.clone().prepare(opt);
|
||||
cmd.execute(opt)
|
||||
.map_err(|err| MyError::new(ErrorKind::Fetch, err, cmd))?;
|
||||
let exit_status = cmd
|
||||
.execute(opt)
|
||||
.map_err(|err| MyError::new(ErrorKind::Fetch, err, cmd.clone()))?;
|
||||
if !exit_status.success() {
|
||||
return Err(MyError::new(
|
||||
ErrorKind::Fetch,
|
||||
io::Error::new(io::ErrorKind::Other, format!("{}", exit_status)),
|
||||
cmd.clone(),
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -152,16 +160,32 @@ impl System {
|
||||
pub fn compile(&self, opt: &Opt) -> Result<()> {
|
||||
if let Some(compile) = &self.compile {
|
||||
let cmd = compile.clone().prepare(opt);
|
||||
cmd.execute(opt)
|
||||
.map_err(|err| MyError::new(ErrorKind::Compile, err, cmd))?;
|
||||
let exit_status = cmd
|
||||
.execute(opt)
|
||||
.map_err(|err| MyError::new(ErrorKind::Compile, err, cmd.clone()))?;
|
||||
if !exit_status.success() {
|
||||
return Err(MyError::new(
|
||||
ErrorKind::Fetch,
|
||||
io::Error::new(io::ErrorKind::Other, format!("{}", exit_status)),
|
||||
cmd.clone(),
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn install(&self, opt: &Opt) -> Result<()> {
|
||||
let cmd = self.install.clone().prepare(opt);
|
||||
cmd.execute(opt)
|
||||
.map_err(|err| MyError::new(ErrorKind::Install, err, cmd))?;
|
||||
let exit_status = cmd
|
||||
.execute(opt)
|
||||
.map_err(|err| MyError::new(ErrorKind::Install, err, cmd.clone()))?;
|
||||
if !exit_status.success() {
|
||||
return Err(MyError::new(
|
||||
ErrorKind::Fetch,
|
||||
io::Error::new(io::ErrorKind::Other, format!("{}", exit_status)),
|
||||
cmd.clone(),
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user