Skip to content

Commit

Permalink
fix(exit): This fixes a regression which was introduced, we should se…
Browse files Browse the repository at this point in the history
…arch for contains otherwise the installer does not exit when warnings are detected. Closes #32

Signed-off-by: dark0dave <[email protected]>
  • Loading branch information
dark0dave committed Nov 25, 2023
1 parent 78066b0 commit b3dbf52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[derive(Debug)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum State {
RequiresInput { question: String },
InProgress,
Expand Down
17 changes: 15 additions & 2 deletions src/weidu_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,26 @@ fn string_looks_like_question(weidu_output: &str) -> bool {

fn detect_weidu_finished_state(weidu_output: &str) -> Option<State> {
let comparable_output = weidu_output.trim().to_lowercase();
if WEIDU_FAILED_WITH_ERROR.eq(&comparable_output) {
if comparable_output.contains(WEIDU_FAILED_WITH_ERROR) {
Some(State::CompletedWithErrors {
error_details: comparable_output,
})
} else if WEIDU_COMPLETED_WITH_WARNINGS.eq(&comparable_output) {
} else if comparable_output.contains(WEIDU_COMPLETED_WITH_WARNINGS) {
Some(State::CompletedWithWarnings)
} else {
None
}
}

#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_exit_warnings() {
let test = "INSTALLED WITH WARNINGS Additional equipment for Thieves and Bards";
assert_eq!(
detect_weidu_finished_state(test),
Some(State::CompletedWithWarnings)
)
}
}

0 comments on commit b3dbf52

Please sign in to comment.