-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
44 lines (34 loc) · 963 Bytes
/
index.js
File metadata and controls
44 lines (34 loc) · 963 Bytes
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
const Watcher = require('@parcel/watcher');
const { exec } = require('child_process');
const IS_WIN = true;
const DIR_TO_WATCH = 'path\\to\\dir\\to\\watch';
const WATCHMAN_BIN_PATH = 'path\\to\\watchman\\bin';
const addWatchmanToProcessPath = () => {
if (IS_WIN) {
process.env.PATH += `;${WATCHMAN_BIN_PATH}`;
exec('watchman --version', (error, stdout) => {
if (error) {
console.log('Watchman is inactive');
return;
}
console.log('Watchman version:', stdout);
});
}
};
addWatchmanToProcessPath();
const run = async () => {
await Watcher.subscribe(DIR_TO_WATCH, (err, events) => {
if (err) {
console.log('err: ', err);
}
events.forEach((event) => {
console.log(event);
});
}, {
backend: 'watchman',
});
}
run().then(() => {
}).catch((err) => {
console.log('err: ', err);
});