Skip to content

Commit d6c3637

Browse files
committed
fix: close dev app when user exits through terminal
1 parent 7a5319f commit d6c3637

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/esbuild-plugins/start-app/start-app-plugin.ts

+8
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,17 @@ export const startAppPlugin = (params: {
4848
.addTransformer(formatChildOutputLine)
4949
.start();
5050

51+
const onProcessKilled = async () => {
52+
// @ts-expect-error
53+
process.kill(-child.pid);
54+
};
55+
56+
process.on("SIGINT", onProcessKilled);
57+
5158
const onExit = async () => {
5259
await program.esbuildCtx.cancel();
5360
await program.esbuildCtx.dispose();
61+
process.off("exit", onProcessKilled);
5462
};
5563

5664
child.on("exit", onExit);

0 commit comments

Comments
 (0)