Raku / ake

A Raku make-a-like inspired by rake
Artistic License 2.0
12 stars 10 forks source link

Pass the current task into the block #7

Closed AlexDaniel closed 5 years ago

AlexDaniel commented 7 years ago

Otherwise there's no easy way to get the required information sometimes, as far as I can see. Block params are not used anyway, and passing it like this will make it available in $_.

I needed it when I wanted to use a junction as a task name (e.g. task ‘test’ | ‘t’, { … }), but still be able to see which one was used exactly. Sure, I can dive into @*ARGS but that's less than awesome.

From the top of my head:

     method execute { 
         return unless self.cond.();
         for self.deps -> $d { execute($d); }
-        self.body.(); 
+        self.body.(self); 
     }

+    method Str() {
+        $.name
+    }