mirror of
https://github.com/actions/labeler.git
synced 2025-12-19 08:38:15 +00:00
build
This commit is contained in:
18
node_modules/prompts/lib/index.js
generated
vendored
18
node_modules/prompts/lib/index.js
generated
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
const prompts = require('./prompts');
|
||||
|
||||
const passOn = ['suggest', 'format', 'onState', 'validate', 'onRender'];
|
||||
const passOn = ['suggest', 'format', 'onState', 'validate', 'onRender', 'type'];
|
||||
const noop = () => {};
|
||||
|
||||
/**
|
||||
@@ -16,7 +16,7 @@ async function prompt(questions=[], { onSubmit=noop, onCancel=noop }={}) {
|
||||
const answers = {};
|
||||
const override = prompt._override || {};
|
||||
questions = [].concat(questions);
|
||||
let answer, question, quit, name, type;
|
||||
let answer, question, quit, name, type, lastPrompt;
|
||||
|
||||
const getFormattedAnswer = async (question, answer, skipValidation = false) => {
|
||||
if (!skipValidation && question.validate && question.validate(answer) !== true) {
|
||||
@@ -28,13 +28,22 @@ async function prompt(questions=[], { onSubmit=noop, onCancel=noop }={}) {
|
||||
for (question of questions) {
|
||||
({ name, type } = question);
|
||||
|
||||
// evaluate type first and skip if type is a falsy value
|
||||
if (typeof type === 'function') {
|
||||
type = await type(answer, { ...answers }, question)
|
||||
question['type'] = type
|
||||
}
|
||||
if (!type) continue;
|
||||
|
||||
// if property is a function, invoke it unless it's a special function
|
||||
for (let key in question) {
|
||||
if (passOn.includes(key)) continue;
|
||||
let value = question[key];
|
||||
question[key] = typeof value === 'function' ? await value(answer, { ...answers }, question) : value;
|
||||
question[key] = typeof value === 'function' ? await value(answer, { ...answers }, lastPrompt) : value;
|
||||
}
|
||||
|
||||
lastPrompt = question;
|
||||
|
||||
if (typeof question.message !== 'string') {
|
||||
throw new Error('prompt message is required');
|
||||
}
|
||||
@@ -42,9 +51,6 @@ async function prompt(questions=[], { onSubmit=noop, onCancel=noop }={}) {
|
||||
// update vars in case they changed
|
||||
({ name, type } = question);
|
||||
|
||||
// skip if type is a falsy value
|
||||
if (!type) continue;
|
||||
|
||||
if (prompts[type] === void 0) {
|
||||
throw new Error(`prompt type (${type}) is not defined`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user