diff --git a/src/plugin.rs b/src/plugin.rs index 73f0bba..2e50034 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -1,12 +1,12 @@ use crate::config; use std::ffi::OsStr; -use std::process::Command; +use std::process::{Command, Output}; pub trait Plugin { /// The optional name of the plugin. fn name(&self) -> Option; - fn run(&self, env_vars: I) -> Result, Box> + fn run(&self, env_vars: I) -> Result<(String, Output), Box> where I: IntoIterator, K: AsRef, @@ -59,7 +59,8 @@ impl Plugin for ExecutablePlugin { self.name.clone() } - fn run(&self, env_vars: I) -> Result, Box> + #[must_use] + fn run(&self, env_vars: I) -> Result<(String, Output), Box> where I: IntoIterator, K: AsRef, @@ -69,12 +70,7 @@ impl Plugin for ExecutablePlugin { let cmd = cmd.args(&self.args).envs(env_vars); let output = cmd.output()?; let name = self.name().unwrap_or("".to_string()); - if output.status.success() { - log::info!("Successfully run plugin {}", &name); - } else { - log::error!("Plugin {} did not run successful", &name); - } - Ok(output.stdout) + Ok((name, output)) } fn panic(&self) -> bool { diff --git a/src/project.rs b/src/project.rs index fe7dcc1..9e5aa41 100644 --- a/src/project.rs +++ b/src/project.rs @@ -310,7 +310,21 @@ impl Project { ); let result = plugin.run(envs); match result { - Ok(res) => log::info!("[{}] {}", name, String::from_utf8_lossy(res.as_slice())), + Ok((name, output)) => { + let stdout = String::from_utf8_lossy(output.stdout.as_slice()); + let stderr = String::from_utf8_lossy(output.stderr.as_slice()); + for line in stdout.lines() { + log::info!("[stdout of {}] {}", name, line); + } + for line in stderr.lines() { + log::error!("[stderr of {}] {}", name, line); + } + if output.status.success() { + log::info!("Plugin {} ran successfully", name); + } else { + log::error!("Plugin {} ran unsuccessfully", name); + } + } Err(e) => { log::error!("Failed to run plugin {}: {}", name, e); if plugin.panic() {