Browse Source

exit the process immediately upon Ctrl+C (#540)

During the deployment selection prompt, don't print out a stack
trace of the "Aborted" error to the user, just exit the process
directly.
master
Nathan Rajlich 8 years ago
committed by Guillermo Rauch
parent
commit
4f64762ffc
  1. 15
      bin/now-deploy.js
  2. 10
      lib/utils/prompt-options.js

15
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)
}
},
{

10
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)

Loading…
Cancel
Save