-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvismapwatch
executable file
·61 lines (55 loc) · 1.68 KB
/
vismapwatch
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
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env php
<?php
/**
* @file
* File watcher controller for the visual sitemap.
*/
define('ROOT', dirname(__FILE__));
use AKlump\LoftLib\Bash\Bash;
use AKlump\LoftLib\Bash\Color;
use Illuminate\Filesystem\Filesystem;
use JasonLewis\ResourceWatcher\Tracker;
use JasonLewis\ResourceWatcher\Watcher;
try {
require ROOT . '/includes/bootstrap.inc';
// Watch for and build on changes.
$watcher = new Watcher(new Tracker(), new Filesystem());
$listener = $watcher->watch($definition->getPath());
$listener->modify(function () use ($cli, $definition_file) {
echo '.';
try {
Bash::exec([
ROOT . '/vismap',
$definition_file,
$cli->hasFlag('f') ? '-f' : '',
$cli->hasParam('out') ? '--out=' . $cli->getParam('out') : '',
]);
}
catch (\Exception $exception) {
echo Color::wrap('red', trim($exception->getMessage()));
}
});
$poll_interval = 1;
echo "Watching for changes every $poll_interval seconds..." . PHP_EOL;
echo "Press CTRL-C to exit" . PHP_EOL;
echo '.';
try {
Bash::exec([
ROOT . '/vismap',
$definition_file,
$cli->hasFlag('f') ? '-f' : '',
$cli->hasParam('dev') ? '--dev=' . $cli->getParam('dev') : '',
$cli->hasParam('out') ? '--out=' . $cli->getParam('out') : '',
$cli->hasParam('theme') ? '--theme=' . $cli->getParam('theme') : '',
$cli->hasParam('state') ? '--state=' . $cli->getParam('state') : '',
]);
}
catch (\Exception $exception) {
echo Color::wrap('red', trim($exception->getMessage()));
}
$watcher->start($poll_interval * 1000000);
}
catch (\Exception $exception) {
echo Color::wrap('red', $exception->getMessage() . PHP_EOL);
exit(1);
}