Initial
This commit is contained in:
20
scripts/start-api.mjs
Normal file
20
scripts/start-api.mjs
Normal file
@@ -0,0 +1,20 @@
|
||||
import { spawn } from 'node:child_process';
|
||||
|
||||
const mode = process.argv[2] || 'development';
|
||||
const watch = process.argv.includes('--watch');
|
||||
const command = watch ? 'nodemon' : 'node';
|
||||
const args = watch ? ['server/index.js'] : ['server/index.js'];
|
||||
|
||||
const child = spawn(command, args, {
|
||||
stdio: 'inherit',
|
||||
shell: process.platform === 'win32',
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_ENV: mode
|
||||
}
|
||||
});
|
||||
|
||||
child.on('exit', (code, signal) => {
|
||||
if (signal) process.kill(process.pid, signal);
|
||||
process.exit(code ?? 0);
|
||||
});
|
||||
Reference in New Issue
Block a user