问题描述
const promptForMissingOptions = async (options) => {
const questions = [];
if (!options.name) {
questions.push({
type: "input",name: "name",message: "Name:",});
}
if (!options.file) {
questions.push({
type: "checkBox",name: "lots",message: "Select the categories:",pageSize: 30,choices: () => {
const files = helpers.getFileNames();
return Object.keys(files);
},});
}
if (answers.lots) {
questions.push({
type: "checkBox",name: "files",message: "Select the files:",pageSize: 50,choices: () => {
const choices = helpers.getFileNames();
return Object.keys(
Object.keys(x)
.filter((key) => answers.lots.includes(key))
.reduce((obj,key) => {
obj[key] = x[key];
return obj;
},{})
).reduce(
(r,k) =>
r.concat(
new inquirer.Separator(
chalk.underline.bold.bgmagenta(
"------------------------ " + k + " ------------------------"
)
),choices[k]
),[]
);
},});
}
const answers = await inquirer.prompt(questions);
return {
files: options.file ? [options.file] : answers.files,name: options.name || answers.name,};
};
let options = await promptForMissingOptions(options);
我在这里尝试了解决方法:Is there a way to use previous answers in inquirer when presenting a prompt (inquirer v6)?
哪个不适用于我的案子
我该如何解决?
谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)