Skip to content

Commit

Permalink
Don't evaluate comment lines if ignore-comment is set
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Oct 5, 2022
1 parent d27b720 commit 709b647
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,21 @@ impl<'src, D> Recipe<'src, D> {
}
let line = lines.next().unwrap();
line_number += 1;
evaluated += &evaluator.evaluate_line(line, continued)?;
if !comment_line {
evaluated += &evaluator.evaluate_line(line, continued)?;
}
if line.is_continuation() && !comment_line {
continued = true;
evaluated.pop();
} else {
break;
}
}

if comment_line {
continue;
}

let mut command = evaluated.as_str();

if quiet_command {
Expand All @@ -142,10 +149,6 @@ impl<'src, D> Recipe<'src, D> {
command = &command[1..];
}

if comment_line {
continue;
}

if command.is_empty() {
continue;
}
Expand Down
14 changes: 14 additions & 0 deletions tests/ignore_comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,17 @@ fn continuations_with_echo_comments_true() {
.stderr("# comment lines can be continued echo something-useful\n")
.run();
}

#[test]
fn dont_evalute_comments() {
Test::new()
.justfile(
"
set ignore-comments
some_recipe:
# {{ error('foo') }}
",
)
.run();
}

0 comments on commit 709b647

Please sign in to comment.