const fs = require('fs'); const {execSync} = require('child_process'); // this is for fix because the event fire twice let twiceFix = false; function compileAll(event, fname) { if (event == 'change' && twiceFix) { console.log(`${fname} as changed`); twiceFix = false; execSync('node build.js'); } twiceFix = true; } console.log('Adding watcher for ui/css/omlink.scss'); fs.watch('ui/css/omlink.scss', function (event, fname) { compileAll(event, fname); }); console.log('Adding watcher for ui/js/onlink.js'); fs.watch('ui/js/omlink.js', function (event, fname) { compileAll(event, fname); });