Skip to content

Commit 4258331

Browse files
committed
extract example based on .modified unless --force
1 parent f39e6d4 commit 4258331

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

util/extract-examples.p6

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ multi sub walk(Str $s is copy, @context) {
4040

4141
my &verbose = sub (|c) {};
4242

43-
sub MAIN(Str :$source-path!, Str :$prefix!, Str :$exclude = ".git", Bool :v(:verbose($v)), *@files) {
43+
sub MAIN(Str :$source-path!, Str :$prefix!, Str :$exclude = ".git", Bool :v(:verbose($v)), Bool :$force, *@files) {
4444
my \exclude = none(flat <. ..>, $exclude.split(','));
4545

4646
@files ||= gather for $source-path {
@@ -52,6 +52,8 @@ sub MAIN(Str :$source-path!, Str :$prefix!, Str :$exclude = ".git", Bool :v(:ver
5252

5353
for @files».IO -> $file {
5454
my $out-file-path = IO::Path.new($prefix ~ $file.abspath.substr($source-path.IO.abspath.chars, $file.abspath.chars - $source-path.IO.abspath.chars - 5) ~ '.p6');
55+
next if !$force && $out-file-path.f && $file.modified < $out-file-path.modified;
56+
5557
mkdir $out-file-path.volume ~ $out-file-path.dirname;
5658
$*OUT = open($out-file-path, :w) // die "can not open $out-file-path";
5759

0 commit comments

Comments
 (0)