🧱 Writes script to watch for changes and trigger re-build
This commit is contained in:
20
services/watch-for-changes.js
Normal file
20
services/watch-for-changes.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const fs = require('fs');
|
||||
const { exec } = require('child_process');
|
||||
|
||||
const configFile = './public/conf.yml';
|
||||
|
||||
console.log(`Watching for file changes on ${configFile}`);
|
||||
|
||||
fs.watch(configFile, (eventType, filename) => {
|
||||
if (filename && eventType === 'change') {
|
||||
console.log(`${filename} file Changed, running build...`);
|
||||
exec('yarn build', (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error(`exec error: ${error}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
console.error(`stderr: ${stderr}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user