freeptcha/gulpfile.js

33 lines
929 B
JavaScript
Raw Normal View History

2023-06-23 13:39:30 +02:00
const gulp = require('gulp');
const log = require('gulplog');
const { spawn } = require('child_process');
const package = require('./package.json');
gulp.task('dev', (cb) => {
log.info('Running in development mode');
/** @type {import('child_process').ChildProcessWithoutNullStreams} */
let node = null;
async function spawnNode(cb){
log.info('Spawning node');
if (node !== null) {
node.kill(9);
console.log('----- END PROCESS LOG -----')
// grace period
await new Promise(r => {setTimeout(r, 100)});
}
log.info(`Command: \x1b[35mnode "${package.main}"`);
console.log('----- BEGIN PROCESS LOG -----');
node = spawn('node', [ package.main ], { stdio: 'inherit' });
if (typeof cb == 'function')
cb();
}
gulp.watch('**', { events: 'all' }, spawnNode);
spawnNode();
// cb();
})