Skip to content

Commit

Permalink
Rework file sub to allow body to accept a Task
Browse files Browse the repository at this point in the history
This was an oops in 8102fcb.
  • Loading branch information
AlexDaniel committed Jun 25, 2018
1 parent 7a6d1a7 commit 4972a25
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/Sake.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ my sub touch (Str $filename) {
}

multi sub file(Str $name, &body) {
return make-task($name, sub { &body.(); touch($name) }, :cond(sub { $name.path !~~ :e; }) );
return make-task(
$name,
{ &body($_); touch $name },
:cond(sub { $name.path !~~ :e; })
)
}

multi sub file(Pair $name-deps, &body) {
Expand All @@ -60,5 +64,10 @@ multi sub file(Pair $name-deps, &body) {
my $f = $name.path;
!($f ~~ :e) || $f.modified < all(map { $_.modified }, grep { $_ ~~ IO::Path }, @deps);
};
return make-task($name, sub { &body.(); touch($name) }, :@deps, :cond($cond));
return make-task(
$name,
{ &body($_); touch $name },
:@deps,
:cond($cond)
)
}

0 comments on commit 4972a25

Please sign in to comment.