UNPKG

@em-cli/shared

Version:

脚手架工具方法包

36 lines (34 loc) 880 B
import fuzzy from 'fuzzy'; import inquirer from "./"; export class SingleInquire { async checkboxPlus({ choices, ...options }) { return await inquirer.prompt([{ ...options, type: 'checkbox-plus', highlight: true, searchable: true, validate: function (answer) { if (answer.length == 0) { return 'You must choose at least one repo.'; } return true; }, source: (answersSoFar, input) => { input = input || ''; return new Promise(function (resolve) { const fuzzyResult = fuzzy.filter(input, choices, { extract: function (item) { return item.name; } }); const data = fuzzyResult.map(function (element) { return element.original; }); resolve(data); }); } }]); } }