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
|
// exclusive_with : List
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
struct Cmd {
|
struct Cmd {
|
||||||
exe: String,
|
exe: String,
|
||||||
params: Vec<String>,
|
params: Vec<String>,
|
||||||
@ -36,7 +36,7 @@ struct Cmd {
|
|||||||
env: HashMap<String, String>,
|
env: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub(crate) struct ActualCmd {
|
pub(crate) struct ActualCmd {
|
||||||
exe: String,
|
exe: String,
|
||||||
params: Vec<String>,
|
params: Vec<String>,
|
||||||
@ -143,8 +143,16 @@ impl System {
|
|||||||
pub fn fetch(&self, opt: &Opt) -> Result<()> {
|
pub fn fetch(&self, opt: &Opt) -> Result<()> {
|
||||||
if let Some(fetch) = &self.fetch {
|
if let Some(fetch) = &self.fetch {
|
||||||
let cmd = fetch.clone().prepare(opt);
|
let cmd = fetch.clone().prepare(opt);
|
||||||
cmd.execute(opt)
|
let exit_status = cmd
|
||||||
.map_err(|err| MyError::new(ErrorKind::Fetch, err, 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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -152,16 +160,32 @@ impl System {
|
|||||||
pub fn compile(&self, opt: &Opt) -> Result<()> {
|
pub fn compile(&self, opt: &Opt) -> Result<()> {
|
||||||
if let Some(compile) = &self.compile {
|
if let Some(compile) = &self.compile {
|
||||||
let cmd = compile.clone().prepare(opt);
|
let cmd = compile.clone().prepare(opt);
|
||||||
cmd.execute(opt)
|
let exit_status = cmd
|
||||||
.map_err(|err| MyError::new(ErrorKind::Compile, err, 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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn install(&self, opt: &Opt) -> Result<()> {
|
pub fn install(&self, opt: &Opt) -> Result<()> {
|
||||||
let cmd = self.install.clone().prepare(opt);
|
let cmd = self.install.clone().prepare(opt);
|
||||||
cmd.execute(opt)
|
let exit_status = cmd
|
||||||
.map_err(|err| MyError::new(ErrorKind::Install, err, 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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user