refactor: prompt.get already returns promise

isekai-main
Barış Soner Uşaklı 3 years ago
parent 057d1d58e3
commit c70eaa0a34

@ -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}`);
}

@ -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',

@ -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,

Loading…
Cancel
Save