GSI - Employe Self Service 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

2 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.promptOnce = exports.prompt = void 0;
  4. const inquirer = require("inquirer");
  5. const error_1 = require("./error");
  6. async function prompt(options, questions) {
  7. const prompts = [];
  8. for (const question of questions) {
  9. if (question.name && options[question.name] === undefined) {
  10. prompts.push(question);
  11. }
  12. }
  13. if (prompts.length && options.nonInteractive) {
  14. const missingOptions = Array.from(new Set(prompts.map((p) => p.name))).join(", ");
  15. throw new error_1.FirebaseError(`Missing required options (${missingOptions}) while running in non-interactive mode`, {
  16. children: prompts,
  17. });
  18. }
  19. const answers = await inquirer.prompt(prompts);
  20. Object.keys(answers).forEach((k) => {
  21. options[k] = answers[k];
  22. });
  23. return answers;
  24. }
  25. exports.prompt = prompt;
  26. async function promptOnce(question, options = {}) {
  27. question.name = question.name || "question";
  28. await prompt(options, [question]);
  29. return options[question.name];
  30. }
  31. exports.promptOnce = promptOnce;