pnpm devでCtrl+Cで終了させてもプロセスが完全に殺せないのを修正 (#10914)

This commit is contained in:
tamaina 2023-05-29 06:37:13 +09:00 committed by GitHub
parent a80003cde5
commit 7cbd852fe5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,11 +44,17 @@ const fs = require('fs');
if (!stat) throw new Error('not exist yet');
if (stat.size === 0) throw new Error('not built yet');
await execa('pnpm', ['start'], {
const subprocess = await execa('pnpm', ['start'], {
cwd: __dirname + '/../',
stdout: process.stdout,
stderr: process.stderr,
});
// なぜかworkerだけが終了してmasterが残るのでその対策
process.on('SIGINT', () => {
subprocess.kill('SIGINT');
process.exit(0);
});
} catch (e) {
await new Promise(resolve => setTimeout(resolve, 3000));
start();