init: gulp dev

This commit is contained in:
b1ek 2023-06-23 21:39:30 +10:00
parent f3044eb363
commit 018d4099e9
Signed by: blek
GPG Key ID: 14546221E3595D0C
4 changed files with 2430 additions and 8 deletions

32
gulpfile.js Normal file
View File

@ -0,0 +1,32 @@
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();
})

View File

@ -9,7 +9,6 @@ fastify.register(require('@fastify/static'), {
prefix: '/'
});
// fastify.get('')
fastify.listen({ port: process.env.APP_PORT ?? 8000 }, (err, address) => {
if (err) throw err;
console.log(`Listening on ${address}`);

View File

@ -7,9 +7,11 @@
"dependencies": {
"@fastify/static": "^6.10.2",
"dotenv": "^16.3.1",
"fastify": "^4.18.0"
"fastify": "^4.18.0",
"gulp": "^4.0.2",
"sharp": "^0.32.1"
},
"scripts": {
"dev": "node index.js"
"dev": "gulp dev"
}
}

2399
yarn.lock

File diff suppressed because it is too large Load Diff