Skip to content

Commit

Permalink
use henrikbjorn/lurker instead of jasonlewis/resource-watcher
Browse files Browse the repository at this point in the history
* if has less dependancies and will cause less conflicts
* uses inotify if present
  • Loading branch information
agallou committed Jan 14, 2016
1 parent da42932 commit 28be863
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions classes/prompt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

namespace mageekguy\atoum\autoloop;

use Illuminate\Filesystem\Filesystem;
use JasonLewis\ResourceWatcher\Event;
use JasonLewis\ResourceWatcher\Resource\FileResource;
use JasonLewis\ResourceWatcher\Tracker;
use JasonLewis\ResourceWatcher\Watcher;
use Lurker\Event\FilesystemEvent;
use Lurker\ResourceWatcher;

class prompt extends \mageekguy\atoum\script\prompt
{
Expand All @@ -27,32 +24,34 @@ class prompt extends \mageekguy\atoum\script\prompt
*/
public function ask($message)
{

$runAgainText = "Press <Enter> to reexecute, press any other key and <Enter> to stop...";
if ($message != $runAgainText) {
return parent::ask($message);
}

$watcher = new Watcher(new Tracker, new Filesystem);
/** @var \mageekguy\atoum\writers\std\out $outputWriter */
$outputWriter = $this->getOutputWriter();

$onEvent = function(Event $event, FileResource $fileResource, $path) use ($watcher, $outputWriter) {
$outputWriter->write($fileResource->getPath() . " has been modified." . PHP_EOL);
$watcher = new ResourceWatcher;

$onEvent = function(FilesystemEvent $event) use ($watcher, $outputWriter) {
$outputWriter->write($event->getResource()->getId() . " has been modified." . PHP_EOL);
$watcher->stop();
};

foreach ($this->configuration->getWatchedFiles() as $watchedFile) {
$watcher->watch($watchedFile)->onAnything($onEvent);
$watcher->track($watchedFile, $watchedFile);
$watcher->addListener($watchedFile, $onEvent);
}

foreach ($this->getRunner()->getTestPaths() as $path) {
$watcher->watch($path)->onAnything($onEvent);
$watcher->track($path, $path);
$watcher->addListener($path, $onEvent);
}

$outputWriter->write('Waiting for a file to change to run the test(s)... (Use CTRL+C to stop)'. PHP_EOL);

$watcher->start(10000);
$watcher->start();

return '';
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
},
"require": {
"atoum/atoum": ">=2.5.0,<3.0",
"jasonlewis/resource-watcher": ">=1.1.1,<2.0"
"henrikbjorn/lurker": ">=1.1,<2.0"
}
}

0 comments on commit 28be863

Please sign in to comment.