I run a nestjs server in nodemon,like follow
const runner = nodemon({
script: 'src/main.ts',
ext: 'js,json,ts',
watch: ['src'],
ignore: ['.git', 'node_modules', 'dist', 'scripts'],
execMap: {
ts: 'eslint "{src,apps,libs,test}/**/*.ts" --fix && node -r @swc/register -r module-alias/register',
},
env: {
NODE_ENV: environment(),
},
cwd: path.resolve(__dirname, '..', '..'),
spawn: true,
});
runner.once(
'start',
() => {
ora('Server is in starting...').start();
},
);
and in child process
main.ts
await app.listen(appConfig.port, appConfig.host, () => {
console.log();
console.log('Server has started:');
const listens: string[] = [];
const nets = networkInterfaces();
// in here stop all ora spinner,ora().clear() not work
Object.entries(nets).forEach(([_, net]) => {
if (net) {
for (const item of net) {
if (item.family === 'IPv4') listens.push(item.address);
}
}
});
const urls = listens.map(
(l) =>
`${appConfig.https ? 'https' : 'http'}://${l}:${
appConfig.port
}`,
);
if (urls.length > 0) {
console.log(`- Local: ${chalk.green.underline(urls[0])}`);
}
if (urls.length > 1) {
console.log(`- Network: ${chalk.green.underline(urls[1])}`);
}
});
and I want to stop ora
spinner after server started
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too