diff --git a/src/config.rs b/src/config.rs index 7574ca7a..e4ff3495 100644 --- a/src/config.rs +++ b/src/config.rs @@ -164,6 +164,7 @@ pub struct Composer { /// Configuration file pub struct ConfigFile { pre_commands: Option, + post_commands: Option, commands: Option, git_repos: Option>, predefined_git_repos: Option, @@ -416,6 +417,11 @@ impl Config { &self.config_file.pre_commands } + /// The list of commands to run at the end of all steps + pub fn post_commands(&self) -> &Option { + &self.config_file.post_commands + } + /// The list of custom steps. pub fn commands(&self) -> &Option { &self.config_file.commands diff --git a/src/main.rs b/src/main.rs index 0a3b2070..eceadce5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -350,6 +350,15 @@ fn run() -> Result<()> { dragonfly::audit_packages(&sudo).ok(); } + let mut post_command_failed = false; + if let Some(commands) = config.post_commands() { + for (name, command) in commands { + if generic::run_custom_command(&name, &command, &ctx).is_err() { + post_command_failed = true; + } + } + } + if config.keep_at_end() { print_info("\n(R)eboot\n(S)hell\n(Q)uit"); loop { @@ -369,7 +378,7 @@ fn run() -> Result<()> { } } - if runner.report().data().iter().any(|(_, result)| result.failed()) { + if post_command_failed || runner.report().data().iter().any(|(_, result)| result.failed()) { Err(StepFailed.into()) } else { Ok(())