diff --git a/bin/now-deploy.js b/bin/now-deploy.js index 7a8a8d8..3af453b 100755 --- a/bin/now-deploy.js +++ b/bin/now-deploy.js @@ -348,7 +348,7 @@ async function sync({ token, config: { currentTeam, user } }) { let meta await retry( - async bail => { + async () => { try { meta = await readMetaData(path, { deploymentType, @@ -399,8 +399,13 @@ async function sync({ token, config: { currentTeam, user } }) { ] ]) } catch (err) { - console.error(err) - return bail() + if (err.code === 'USER_ABORT') { + if (debug) { + console.log(`> [debug] Got Ctrl+C, aborting`) + } + return exit(1) + } + throw err } if (debug) { @@ -412,9 +417,9 @@ async function sync({ token, config: { currentTeam, user } }) { // Invoke async-retry and try again with the explicit deployment type throw err } + } else { + return stopDeployment(err) } - - return stopDeployment(err) } }, { diff --git a/lib/utils/prompt-options.js b/lib/utils/prompt-options.js index 0ee2021..a698a99 100644 --- a/lib/utils/prompt-options.js +++ b/lib/utils/prompt-options.js @@ -1,7 +1,9 @@ // Packages const chalk = require('chalk') -module.exports = function(opts) { +module.exports = promptOptions + +function promptOptions(opts) { return new Promise((resolve, reject) => { opts.forEach(([, text], i) => { console.log(`${chalk.gray('>')} [${chalk.bold(i + 1)}] ${text}`) @@ -15,10 +17,12 @@ module.exports = function(opts) { process.stdin.removeListener('data', ondata) } + // Ctrl + C if (s === '\u0003') { cleanup() - reject(new Error('Aborted')) - return + const err = new Error('Aborted') + err.code = 'USER_ABORT' + return reject(err) } const n = Number(s)