Skip to content

Commit

Permalink
Merge pull request #22687 from storybookjs/chore/ctrl-c-on-init
Browse files Browse the repository at this point in the history
CLI: Only handle CTRL + C on init event
  • Loading branch information
yannbf authored May 22, 2023
2 parents 1853caa + 83e60b5 commit 0de7a03
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions code/lib/core-server/src/withTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,16 @@ export async function withTelemetry<T>(
options: TelemetryOptions,
run: () => Promise<T>
): Promise<T> {
// We catch Ctrl+C user interactions to be able to detect a cancel event
process.on('SIGINT', async () => {
if (!options.cliOptions.disableTelemetry) {
await telemetry('canceled', { eventType }, { stripMetadata: true, immediate: true });
process.exit(0);
}
if (eventType === 'init') {
// We catch Ctrl+C user interactions to be able to detect a cancel event
process.on('SIGINT', async () => {
if (!options.cliOptions.disableTelemetry) {
await telemetry('canceled', { eventType }, { stripMetadata: true, immediate: true });
}

process.exit(0);
});
process.exit(0);
});
}

if (!options.cliOptions.disableTelemetry)
telemetry('boot', { eventType }, { stripMetadata: true });
Expand Down

0 comments on commit 0de7a03

Please sign in to comment.