mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
feat(cli): impl BuildOutcome::status_code
This commit is contained in:
parent
3fa5b4363e
commit
a82b403aa4
2 changed files with 13 additions and 9 deletions
|
@ -26,6 +26,16 @@ pub enum BuildOutcome {
|
||||||
Errors,
|
Errors,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BuildOutcome {
|
||||||
|
pub fn status_code(&self) -> i32 {
|
||||||
|
match self {
|
||||||
|
Self::NoProblems => 0,
|
||||||
|
Self::OnlyWarnings => 1,
|
||||||
|
Self::Errors => 2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct BuiltFile {
|
pub struct BuiltFile {
|
||||||
pub binary_path: PathBuf,
|
pub binary_path: PathBuf,
|
||||||
pub outcome: BuildOutcome,
|
pub outcome: BuildOutcome,
|
||||||
|
|
|
@ -196,13 +196,6 @@ pub fn build(target: &Triple, matches: &ArgMatches, config: BuildConfig) -> io::
|
||||||
.strip_prefix(env::current_dir().unwrap())
|
.strip_prefix(env::current_dir().unwrap())
|
||||||
.unwrap_or(&binary_path);
|
.unwrap_or(&binary_path);
|
||||||
|
|
||||||
// Return a nonzero exit code if there were problems
|
|
||||||
let status_code = match outcome {
|
|
||||||
BuildOutcome::NoProblems => 0,
|
|
||||||
BuildOutcome::OnlyWarnings => 1,
|
|
||||||
BuildOutcome::Errors => 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
// No need to waste time freeing this memory,
|
// No need to waste time freeing this memory,
|
||||||
// since the process is about to exit anyway.
|
// since the process is about to exit anyway.
|
||||||
std::mem::forget(arena);
|
std::mem::forget(arena);
|
||||||
|
@ -213,7 +206,8 @@ pub fn build(target: &Triple, matches: &ArgMatches, config: BuildConfig) -> io::
|
||||||
total_time.as_millis()
|
total_time.as_millis()
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(status_code)
|
// Return a nonzero exit code if there were problems
|
||||||
|
Ok(outcome.status_code())
|
||||||
}
|
}
|
||||||
BuildAndRun { roc_file_arg_index } => {
|
BuildAndRun { roc_file_arg_index } => {
|
||||||
let mut cmd = Command::new(binary_path);
|
let mut cmd = Command::new(binary_path);
|
||||||
|
@ -232,7 +226,7 @@ pub fn build(target: &Triple, matches: &ArgMatches, config: BuildConfig) -> io::
|
||||||
}
|
}
|
||||||
|
|
||||||
match outcome {
|
match outcome {
|
||||||
BuildOutcome::Errors => Ok(2),
|
BuildOutcome::Errors => Ok(outcome.status_code()),
|
||||||
_ => roc_run(cmd.current_dir(original_cwd)),
|
_ => roc_run(cmd.current_dir(original_cwd)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue