diff --git a/packages/cli/commands/project/dev.js b/packages/cli/commands/project/dev.js index 58c23d35f..b2dd15479 100644 --- a/packages/cli/commands/project/dev.js +++ b/packages/cli/commands/project/dev.js @@ -338,7 +338,7 @@ exports.handler = async options => { await LocalDev.start(); - handleExit(() => LocalDev.stop()); + handleExit(({ isSIGHUP }) => LocalDev.stop(!isSIGHUP)); }; exports.builder = yargs => { diff --git a/packages/cli/lib/LocalDevManager.js b/packages/cli/lib/LocalDevManager.js index 010bf0056..3c8ea144f 100644 --- a/packages/cli/lib/LocalDevManager.js +++ b/packages/cli/lib/LocalDevManager.js @@ -141,25 +141,30 @@ class LocalDevManager { this.compareLocalProjectToDeployed(runnableComponents); } - async stop() { - SpinniesManager.add('cleanupMessage', { - text: i18n(`${i18nKey}.exitingStart`), - }); - + async stop(showProgress = true) { + if (showProgress) { + SpinniesManager.add('cleanupMessage', { + text: i18n(`${i18nKey}.exitingStart`), + }); + } await this.stopWatching(); const cleanupSucceeded = await this.devServerCleanup(); if (!cleanupSucceeded) { - SpinniesManager.fail('cleanupMessage', { - text: i18n(`${i18nKey}.exitingFail`), - }); + if (showProgress) { + SpinniesManager.fail('cleanupMessage', { + text: i18n(`${i18nKey}.exitingFail`), + }); + } process.exit(EXIT_CODES.ERROR); } - SpinniesManager.succeed('cleanupMessage', { - text: i18n(`${i18nKey}.exitingSucceed`), - }); + if (showProgress) { + SpinniesManager.succeed('cleanupMessage', { + text: i18n(`${i18nKey}.exitingSucceed`), + }); + } process.exit(EXIT_CODES.SUCCESS); } diff --git a/packages/cli/lib/process.js b/packages/cli/lib/process.js index 874372740..83372d07a 100644 --- a/packages/cli/lib/process.js +++ b/packages/cli/lib/process.js @@ -4,12 +4,12 @@ const { logger } = require('@hubspot/cli-lib/logger'); const handleExit = callback => { const terminationSignals = [ 'beforeExit', - 'SIGINT', - 'SIGUSR1', - 'SIGUSR2', + 'SIGINT', // Terminal trying to interrupt (Ctrl + C) + 'SIGUSR1', // Start Debugger User-defined signal 1 + 'SIGUSR2', // User-defined signal 2 'uncaughtException', - 'SIGTERM', - 'SIGHUP', + 'SIGTERM', // Represents a graceful termination + 'SIGHUP', // Parent terminal has been closed ]; let exitInProgress = false; @@ -21,7 +21,7 @@ const handleExit = callback => { // Prevent duplicate exit handling if (!exitInProgress) { exitInProgress = true; - await callback(); + await callback({ isSIGHUP: signal === 'SIGHUP' }); } }); });