forked from dienianindya/gsi_ess_mobile
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.1 KiB
31 lines
1.1 KiB
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.promptOnce = exports.prompt = void 0;
|
|
const inquirer = require("inquirer");
|
|
const error_1 = require("./error");
|
|
async function prompt(options, questions) {
|
|
const prompts = [];
|
|
for (const question of questions) {
|
|
if (question.name && options[question.name] === undefined) {
|
|
prompts.push(question);
|
|
}
|
|
}
|
|
if (prompts.length && options.nonInteractive) {
|
|
const missingOptions = Array.from(new Set(prompts.map((p) => p.name))).join(", ");
|
|
throw new error_1.FirebaseError(`Missing required options (${missingOptions}) while running in non-interactive mode`, {
|
|
children: prompts,
|
|
});
|
|
}
|
|
const answers = await inquirer.prompt(prompts);
|
|
Object.keys(answers).forEach((k) => {
|
|
options[k] = answers[k];
|
|
});
|
|
return answers;
|
|
}
|
|
exports.prompt = prompt;
|
|
async function promptOnce(question, options = {}) {
|
|
question.name = question.name || "question";
|
|
await prompt(options, [question]);
|
|
return options[question.name];
|
|
}
|
|
exports.promptOnce = promptOnce;
|