Skip to content

Commit

Permalink
Make Foreman exit with code from underlying tool (#20)
Browse files Browse the repository at this point in the history
* Make Foreman exit with code from underlying tool

* Update Changelog
  • Loading branch information
LPGhatguy authored May 20, 2020
1 parent 23c6913 commit 5d90ef3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -58,7 +58,11 @@ fn main() -> Result<(), Box<dyn Error>> {
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(());
Expand Down
1 change: 1 addition & 0 deletions src/tool_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct ToolCache {
}

impl ToolCache {
#[must_use]
pub fn run(source: &str, version: &Version, args: Vec<String>) -> i32 {
log::debug!("Running tool {}@{}", source, version);

Expand Down

0 comments on commit 5d90ef3

Please sign in to comment.