X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fconsolidation%2Frobo%2Fsrc%2FTask%2FBase%2FWatch.php;fp=vendor%2Fconsolidation%2Frobo%2Fsrc%2FTask%2FBase%2FWatch.php;h=3b2152d96fe48a94ebe7f19c3ec4b87e7c24ba34;hp=d7940ac94b3283073389ae73fb76d9b14376036c;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/vendor/consolidation/robo/src/Task/Base/Watch.php b/vendor/consolidation/robo/src/Task/Base/Watch.php index d7940ac94..3b2152d96 100644 --- a/vendor/consolidation/robo/src/Task/Base/Watch.php +++ b/vendor/consolidation/robo/src/Task/Base/Watch.php @@ -1,7 +1,6 @@ taskWatch() - * ->monitor('composer.json', function() { - * $this->taskComposerUpdate()->run(); - * })->monitor('src', function() { - * $this->taskExec('phpunit')->run(); - * })->run(); + * ->monitor( + * 'composer.json', + * function() { + * $this->taskComposerUpdate()->run(); + * } + * )->monitor( + * 'src', + * function() { + * $this->taskExec('phpunit')->run(); + * }, + * \Lurker\Event\FilesystemEvent::ALL + * )->monitor( + * 'migrations', + * function() { + * //do something + * }, + * [ + * \Lurker\Event\FilesystemEvent::CREATE, + * \Lurker\Event\FilesystemEvent::DELETE + * ] + * )->run(); * ?> * ``` */ @@ -49,15 +66,13 @@ class Watch extends BaseTask /** * @param string|string[] $paths * @param \Closure $callable + * @param int|int[] $events * * @return $this */ - public function monitor($paths, \Closure $callable) + public function monitor($paths, \Closure $callable, $events = 2) { - if (!is_array($paths)) { - $paths = [$paths]; - } - $this->monitor[] = [$paths, $callable]; + $this->monitor[] = [(array)$paths, $callable, (array)$events]; return $this; } @@ -77,9 +92,11 @@ class Watch extends BaseTask $closure = $monitor[1]; $closure->bindTo($this->bindTo); foreach ($monitor[0] as $i => $dir) { - $watcher->track("fs.$k.$i", $dir, FilesystemEvent::MODIFY); + foreach ($monitor[2] as $j => $event) { + $watcher->track("fs.$k.$i.$j", $dir, $event); + $watcher->addListener("fs.$k.$i.$j", $closure); + } $this->printTaskInfo('Watching {dir} for changes...', ['dir' => $dir]); - $watcher->addListener("fs.$k.$i", $closure); } }