-
Notifications
You must be signed in to change notification settings - Fork 10
/
IO.pm6
48 lines (35 loc) · 1.07 KB
/
IO.pm6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use Sake::Task;
use Sake::TaskStore;
unit class Sake::Task::IO is Sake::Task;
method modification-time {
$.name.IO.e
?? $.name.IO.modified
!! -∞
}
method execute {
resolve-deps self, :live; # in case the task was added later
await @.deps».readify;
if $.cond() {
with self.body {
my $last-dep = @.deps».modification-time.max;
$last-dep = now if $last-dep == -∞;
sink .(self) if $.modification-time < $last-dep;
}
my &touch = -> $filename { run <touch -->, $filename };
touch $.name.IO;
}
$.ready.keep: $.modification-time unless $.ready;
}
multi sub task(IO $path, &body?) is export {
make-task $path, &body, type => Sake::Task::IO
}
multi sub task(Pair (IO :key($path), :value($deps)), &body?) is export {
make-task $path, &body, deps => $deps.list, type => Sake::Task::IO
}
proto sub file(|) is export {*}
multi sub file(IO() $path, &body?) {
task $path, &body
}
multi sub file(Pair (IO() :key($path), :value($deps)), &body?) {
task $path => $deps, &body
}