mirror of
https://github.com/smartyellow/status.git
synced 2025-01-18 21:47:58 +00:00
33 lines
781 B
JavaScript
33 lines
781 B
JavaScript
'use strict';
|
|
|
|
const chokidar = require('chokidar');
|
|
const dashboard = require('./index');
|
|
|
|
let watcher;
|
|
const handler = async () => {
|
|
console.log('status dashboard watcher triggered, rebuilding...');
|
|
await dashboard.cleanup();
|
|
await dashboard.build();
|
|
process.send({ command: 'reload' });
|
|
};
|
|
|
|
process.on('message', message => {
|
|
switch (message.command) {
|
|
case 'start':
|
|
if (message.path) {
|
|
watcher = chokidar.watch(message.path, {
|
|
ignored: [ /node_modules/, /build/ ],
|
|
});
|
|
|
|
watcher.on('add', handler);
|
|
watcher.on('change', handler);
|
|
watcher.on('unlink', handler);
|
|
}
|
|
break;
|
|
|
|
default:
|
|
console.log(`Status dashboard watcher received unknown command ${message.command}`);
|
|
break;
|
|
}
|
|
});
|