Skip to content

Commit

Permalink
[src/lib;#505][s]:terminate subprocesses on SIGINT
Browse files Browse the repository at this point in the history
  • Loading branch information
olayway committed May 23, 2023
1 parent 75d8334 commit 21f47d9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/cli/src/lib/Installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,15 @@ export default class Installer {
// install flowershow dependencies
logWithSpinner({ symbol: "🌸", msg: `Installing Flowershow dependencies` });
try {
const { stdout, stderr } = await execa("npm", ["install"], {
const subprocess = execa("npm", ["install"], {
cwd: flowershowDir,
});

process.on("SIGINT", () => {
subprocess.kill("SIGINT");
});

const { stdout, stderr } = await subprocess;
log(stdout);
log(stderr);
stopSpinner();
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/lib/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ export default async function build(dir: string) {
const subprocess = execa("npm", ["run", "build"], { cwd: flowershowDir });

subprocess.stdout.pipe(process.stdout);

process.on("SIGINT", () => {
subprocess.kill("SIGINT");
});
}
4 changes: 4 additions & 0 deletions packages/cli/src/lib/buildExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ export default async function buildExport(dir: string) {
const subprocess = execa("npm", ["run", "export"], { cwd: flowershowDir });

subprocess.stdout.pipe(process.stdout);

process.on("SIGINT", () => {
subprocess.kill("SIGINT");
});
}
4 changes: 4 additions & 0 deletions packages/cli/src/lib/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ export default async function preview(dir: string) {
const subprocess = execa("npm", ["run", "dev"], { cwd: flowershowDir });

subprocess.stdout.pipe(process.stdout);

process.on("SIGINT", () => {
subprocess.kill("SIGINT");
});
}

0 comments on commit 21f47d9

Please sign in to comment.