forked from toolkit-for-ynab/toolkit-for-ynab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatch
executable file
·41 lines (28 loc) · 798 Bytes
/
watch
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
#!/usr/bin/env node
const execSync = require('child_process').execSync;
var building = false;
var rebuild = false;
var watcher = require('chokidar').watch('source/**',
{
persistent: true,
ignoreInitial: true,
ignored: ['**/allSettings.js', '**/feedChanges.js']
});
watcher.on('all', function (event, path) {
if (building) {
rebuild = true;
return;
}
console.log('Changes detected, rebuilding...');
building = true;
execSync('./build', { stdio: [0, 1, 2] });
// In case we had a change while we were building.
while (rebuild) {
rebuild = false;
console.log('Changes detected, rebuilding...');
execSync('./build', { stdio: [0, 1, 2] });
}
building = false;
console.log('Watching for changes...');
});
console.log('Watching for changes...');