wasp/waspc/headless-test/start.js
Craig McIlwrath 802e0c5e5d
show error message when database is not running (#1218)
Co-authored-by: Martin Šošić <Martinsos@users.noreply.github.com>
Co-authored-by: Mihovil Ilakovac <mihovil@ilakovac.com>
2023-06-20 14:34:14 -04:00

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)