Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
feat(inquirer): converts rest of inquirer call signatures from callba…
Browse files Browse the repository at this point in the history
…ck to promise
  • Loading branch information
Ryan Garant committed Aug 26, 2018
1 parent a8f0cde commit f2c9b6f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
11 changes: 5 additions & 6 deletions lib/cmds/gists.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ Gists.prototype.run = function() {
'Deleting gist ' + logger.colors.green(options.loggedUser + '/' + options.delete)
)

inquirer.prompt(
[
inquirer
.prompt([
{
type: 'input',
message: 'Are you sure? This action CANNOT be undone. [y/N]',
name: 'confirmation',
},
],
function(answers) {
])
.then(function(answers) {
if (answers.confirmation.toLowerCase() === 'y') {
instance.delete(options.delete, function(err) {
if (err) {
Expand All @@ -106,8 +106,7 @@ Gists.prototype.run = function() {
} else {
logger.log('Not deleted.')
}
}
)
})
})
}

Expand Down
11 changes: 5 additions & 6 deletions lib/cmds/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ Repo.prototype.run = function() {
hooks.invoke('repo.delete', instance, function(afterHooksCallback) {
logger.log('Deleting repo ' + logger.colors.green(options.user + '/' + options.delete))

inquirer.prompt(
[
inquirer
.prompt([
{
type: 'input',
message: 'Are you sure? This action CANNOT be undone. [y/N]',
name: 'confirmation',
},
],
function(answers) {
])
.then(function(answers) {
if (answers.confirmation.toLowerCase() === 'y') {
instance.delete(options.user, options.delete, function(err) {
if (err) {
Expand All @@ -180,8 +180,7 @@ Repo.prototype.run = function() {
} else {
logger.log('Not deleted.')
}
}
)
})
})
}

Expand Down
11 changes: 5 additions & 6 deletions lib/cmds/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ User.logout = function() {
}

User.twoFactorAuthenticator_ = function(payload, user, opt_callback) {
inquirer.prompt(
[
inquirer
.prompt([
{
type: 'input',
message: 'Enter your two-factor code',
name: 'otp',
},
],
function(factor) {
])
.then(function(factor) {
if (!payload.headers) {
payload.headers = []
}
Expand All @@ -182,8 +182,7 @@ User.twoFactorAuthenticator_ = function(payload, user, opt_callback) {
User.authorizationCallback_(user, err, res)
opt_callback && opt_callback(err)
})
}
)
})
}

exports.Impl = User

0 comments on commit f2c9b6f

Please sign in to comment.