From 5d90ef38b3da019864b12588a04b36f8bced163d Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Wed, 20 May 2020 15:06:35 -0700 Subject: [PATCH] Make Foreman exit with code from underlying tool (#20) * Make Foreman exit with code from underlying tool * Update Changelog --- CHANGELOG.md | 3 +++ src/main.rs | 8 ++++++-- src/tool_cache.rs | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe3fd0f..05a688d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Foreman Changelog +## Unreleased +- Fixed Foreman not propagating error codes from underlying tools. ([#20](https://github.com/rojo-rbx/foreman/pull/20)) + ## 1.0.1 - Metadata fix for crates.io release diff --git a/src/main.rs b/src/main.rs index 9288b33..cc53987 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ mod github; mod paths; mod tool_cache; -use std::{env, error::Error, io}; +use std::{env, error::Error, io, process}; use structopt::StructOpt; @@ -58,7 +58,11 @@ fn main() -> Result<(), Box> { ToolCache::download_if_necessary(&tool_spec.source, &tool_spec.version); if let Some(version) = maybe_version { - ToolCache::run(&tool_spec.source, &version, invocation.args); + let exit_code = ToolCache::run(&tool_spec.source, &version, invocation.args); + + if exit_code != 0 { + process::exit(exit_code); + } } return Ok(()); diff --git a/src/tool_cache.rs b/src/tool_cache.rs index dcc141f..bb347de 100644 --- a/src/tool_cache.rs +++ b/src/tool_cache.rs @@ -30,6 +30,7 @@ pub struct ToolCache { } impl ToolCache { + #[must_use] pub fn run(source: &str, version: &Version, args: Vec) -> i32 { log::debug!("Running tool {}@{}", source, version);