mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-28 11:34:41 +03:00
802e0c5e5d
Co-authored-by: Martin Šošić <Martinsos@users.noreply.github.com> Co-authored-by: Mihovil Ilakovac <mihovil@ilakovac.com>
32 lines
898 B
JavaScript
32 lines
898 B
JavaScript
const cp = require('child_process');
|
|
const readline = require('linebyline');
|
|
|
|
function spawn(name, cmd, args, done) {
|
|
const spawnOptions = {
|
|
detached: true,
|
|
};
|
|
const proc = cp.spawn(cmd, args, spawnOptions);
|
|
|
|
// We close stdin stream on the new process because otherwise the start-app
|
|
// process hangs.
|
|
// See https://github.com/wasp-lang/wasp/pull/1218#issuecomment-1599098272.
|
|
proc.stdin.destroy();
|
|
|
|
readline(proc.stdout).on('line', data => {
|
|
console.log(`\x1b[0m\x1b[33m[${name}][out]\x1b[0m ${data}`);
|
|
});
|
|
readline(proc.stderr).on('line', data => {
|
|
console.log(`\x1b[0m\x1b[33m[${name}][err]\x1b[0m ${data}`);
|
|
});
|
|
proc.on('exit', done);
|
|
}
|
|
|
|
// Exit if either child fails
|
|
const cb = (code) => {
|
|
if (code !== 0) {
|
|
process.exit(code);
|
|
}
|
|
}
|
|
spawn('app', 'npm', ['run', 'example-app:start-app'], cb);
|
|
spawn('db', 'npm', ['run', 'example-app:start-db'], cb)
|