Browse Source

Ability to skip confirmation when deleting deployments

master
Leo Lamprecht 8 years ago
parent
commit
26afd83c1a
No known key found for this signature in database GPG Key ID: B08517883D5E0E10
  1. 18
      bin/now-remove.js

18
bin/now-remove.js

@ -14,12 +14,13 @@ import {handleError, error} from '../lib/error'
const argv = minimist(process.argv.slice(2), { const argv = minimist(process.argv.slice(2), {
string: ['config', 'token'], string: ['config', 'token'],
boolean: ['help', 'debug', 'hard'], boolean: ['help', 'debug', 'hard', 'yes'],
alias: { alias: {
help: 'h', help: 'h',
config: 'c', config: 'c',
debug: 'd', debug: 'd',
token: 't' token: 't',
yes: 'y'
} }
}) })
@ -36,6 +37,7 @@ const help = () => {
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token
-y, --yes Skip confirmation
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
@ -64,6 +66,7 @@ if (argv.help || ids.length === 0) {
const debug = argv.debug const debug = argv.debug
const apiUrl = argv.url || 'https://api.zeit.co' const apiUrl = argv.url || 'https://api.zeit.co'
const hard = argv.hard || false const hard = argv.hard || false
const skipConfirmation = argv.yes || false
if (argv.config) { if (argv.config) {
cfg.setConfigFile(argv.config) cfg.setConfigFile(argv.config)
@ -147,10 +150,13 @@ async function remove(token) {
} }
try { try {
const confirmation = (await readConfirmation(matches)).toLowerCase() if (!skipConfirmation) {
if (confirmation !== 'y' && confirmation !== 'yes') { const confirmation = (await readConfirmation(matches)).toLowerCase()
console.log('\n> Aborted')
process.exit(0) if (confirmation !== 'y' && confirmation !== 'yes') {
console.log('\n> Aborted')
process.exit(0)
}
} }
const start = new Date() const start = new Date()

Loading…
Cancel
Save