mirror of
https://github.com/caprover/caprover
synced 2026-05-12 22:50:35 +00:00
Refactor inquirer promt to use async/await
This commit is contained in:
+7
-10
@@ -22,22 +22,19 @@ function generateQuestions() {
|
||||
]
|
||||
}
|
||||
|
||||
function logout() {
|
||||
async function logout() {
|
||||
const questions = generateQuestions()
|
||||
|
||||
printMessage("Logout from a Captain Machine and clear auth info")
|
||||
|
||||
inquirer.prompt(questions).then(answers => {
|
||||
const { captainNameToLogout } = answers
|
||||
const answers = await inquirer.prompt(questions)
|
||||
const { captainNameToLogout } = answers
|
||||
|
||||
if (!captainNameToLogout) {
|
||||
printMessage("\nOperation cancelled by the user...\n")
|
||||
if (!captainNameToLogout) {
|
||||
printMessage("\nOperation cancelled by the user...\n", true)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
MachineHelper.logoutMachine(captainNameToLogout)
|
||||
})
|
||||
MachineHelper.logoutMachine(captainNameToLogout)
|
||||
}
|
||||
|
||||
module.exports = logout
|
||||
|
||||
+13
-15
@@ -216,26 +216,24 @@ const questions = [
|
||||
}
|
||||
]
|
||||
|
||||
function serversetup() {
|
||||
async function serversetup() {
|
||||
printMessage("\nSetup your Captain server\n")
|
||||
|
||||
inquirer.prompt(questions).then(answers => {
|
||||
var captainAddress = `https://${SystemApi.customDomainFromUser}`
|
||||
const answers = await inquirer.prompt(questions)
|
||||
const captainAddress = `https://${SystemApi.customDomainFromUser}`
|
||||
const newMachine = {
|
||||
authToken: LoginApi.token,
|
||||
baseUrl: captainAddress,
|
||||
name: answers.captainName
|
||||
}
|
||||
|
||||
const newMachine = {
|
||||
authToken: LoginApi.token,
|
||||
baseUrl: captainAddress,
|
||||
name: answers.captainName
|
||||
}
|
||||
MachineHelper.addMachine(newMachine)
|
||||
|
||||
MachineHelper.addMachine(newMachine)
|
||||
printMessage(`\n\nCaptain is available at ${captainAddress}`)
|
||||
|
||||
printMessage(`\n\nCaptain is available at ${captainAddress}`)
|
||||
|
||||
printMessage(
|
||||
"\nFor more details and docs see http://www.captainduckduck.com\n\n"
|
||||
)
|
||||
})
|
||||
printMessage(
|
||||
"\nFor more details and docs see http://www.captainduckduck.com\n\n"
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = serversetup
|
||||
|
||||
Reference in New Issue
Block a user