Build MerchantFlow onboarding CRM foundation
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { spawn } from 'node:child_process';
|
||||
import { createRequire } from 'node:module';
|
||||
const require = createRequire(import.meta.url);
|
||||
// Stop both processes together, including when Turbo or Playwright stops this task.
|
||||
const children = [
|
||||
spawn(
|
||||
process.execPath,
|
||||
[require.resolve('typescript/bin/tsc'), '--watch', '--preserveWatchOutput'],
|
||||
{ stdio: 'inherit' },
|
||||
),
|
||||
spawn(process.execPath, ['--watch', 'dist/main.js'], { stdio: 'inherit' }),
|
||||
];
|
||||
let stopping = false;
|
||||
function stop(code = 0) {
|
||||
if (stopping) return;
|
||||
stopping = true;
|
||||
for (const child of children) child.kill('SIGTERM');
|
||||
process.exitCode = code;
|
||||
}
|
||||
process.on('SIGINT', () => stop());
|
||||
process.on('SIGTERM', () => stop());
|
||||
for (const child of children) {
|
||||
child.on('error', (error) => {
|
||||
console.error(error.message);
|
||||
stop(1);
|
||||
});
|
||||
child.on('exit', (code) => {
|
||||
if (!stopping) stop(code ?? 1);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user