forked from getimpactnow/getimpactnow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatch.js
More file actions
27 lines (23 loc) · 633 Bytes
/
Copy pathwatch.js
File metadata and controls
27 lines (23 loc) · 633 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
const chokidar = require("chokidar");
const { spawn } = require("child_process");
// One-liner for current directory
chokidar
.watch("src/", {
awaitWriteFinish: {
stabilityThreshold: 500,
pollInterval: 100,
},
})
.on("change", (event, path) => {
console.log(event, path);
const yarn = spawn("yarn", ["autobuild"]);
yarn.stdout.on("data", (data) => {
console.log(`stdout: ${data}`);
});
yarn.stderr.on("data", (data) => {
console.error(`stderr: ${data}`);
});
yarn.on("close", (code) => {
console.log(`child process exited with code ${code}`);
});
});