Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Foreman exit with code from underlying tool #20

Merged
merged 2 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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