From c70eaa0a34be0969081fed6d9333f4fa437c89a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 18 Oct 2021 17:34:26 -0400 Subject: [PATCH] refactor: prompt.get already returns promise --- install/databases.js | 10 +++------- src/cli/upgrade-plugins.js | 4 +--- src/install.js | 9 +++------ 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/install/databases.js b/install/databases.js index 057de576c6..dbbda8fcff 100644 --- a/install/databases.js +++ b/install/databases.js @@ -3,10 +3,6 @@ const prompt = require('prompt'); const winston = require('winston'); -const util = require('util'); - -const promptGet = util.promisify((schema, callback) => prompt.get(schema, callback)); - const questions = { redis: require('../src/database/redis').questions, mongo: require('../src/database/mongo').questions, @@ -28,17 +24,17 @@ async function getDatabaseConfig(config) { if (config['redis:host'] && config['redis:port']) { return config; } - return await promptGet(questions.redis); + return await prompt.get(questions.redis); } else if (config.database === 'mongo') { if ((config['mongo:host'] && config['mongo:port']) || config['mongo:uri']) { return config; } - return await promptGet(questions.mongo); + return await prompt.get(questions.mongo); } else if (config.database === 'postgres') { if (config['postgres:host'] && config['postgres:port']) { return config; } - return await promptGet(questions.postgres); + return await prompt.get(questions.postgres); } throw new Error(`unknown database : ${config.database}`); } diff --git a/src/cli/upgrade-plugins.js b/src/cli/upgrade-plugins.js index b6cd6ac2a7..fa2b29bda4 100644 --- a/src/cli/upgrade-plugins.js +++ b/src/cli/upgrade-plugins.js @@ -7,7 +7,6 @@ const semver = require('semver'); const fs = require('fs'); const path = require('path'); const nconf = require('nconf'); -const util = require('util'); const { paths, pluginNamePattern } = require('../constants'); @@ -138,9 +137,8 @@ async function upgradePlugins() { prompt.message = ''; prompt.delimiter = ''; - const promptGet = util.promisify((schema, callback) => prompt.get(schema, callback)); prompt.start(); - const result = await promptGet({ + const result = await prompt.get({ name: 'upgrade', description: '\nProceed with upgrade (y|n)?'.reset, type: 'string', diff --git a/src/install.js b/src/install.js index c94e80d32c..98339c1314 100644 --- a/src/install.js +++ b/src/install.js @@ -7,9 +7,6 @@ const prompt = require('prompt'); const winston = require('winston'); const nconf = require('nconf'); const _ = require('lodash'); -const util = require('util'); - -const promptGet = util.promisify((schema, callback) => prompt.get(schema, callback)); const utils = require('./utils'); @@ -147,7 +144,7 @@ async function setupConfig() { } }); } else { - config = await promptGet(questions.main); + config = await prompt.get(questions.main); } await configureDatabases(config); await completeConfigSetup(config); @@ -298,7 +295,7 @@ async function createAdmin() { async function retryPassword(originalResults) { // Ask only the password questions - const results = await promptGet(passwordQuestions); + const results = await prompt.get(passwordQuestions); // Update the original data with newly collected password originalResults.password = results.password; @@ -312,7 +309,7 @@ async function createAdmin() { questions = questions.concat(passwordQuestions); if (!install.values) { - const results = await promptGet(questions); + const results = await prompt.get(questions); return await success(results); } // If automated setup did not provide a user password, generate one,