INNER CODE UNIT · TypeScript
found
dolanmiu/docx · demo/index.ts:45
const found = demos.includes(term) ? [term] : topics.has(term) ? [] : demos.filter((demo) => demo.endsWith(`/${term}`));
const matches = found.length === 1 ? found : search(query);
let demo: string;
if (matches.length === 0) {
console.error(`No demo matches "${term}". Run npm run demo to pick one from the list`);
process.exit(1);
} else if (term && matches.length === 1) {
demo = matches[0];
} else {
const answers = await inquirer.prompt<{ readonly demo: string }>([
{
type: "search",
name: "demo",
message: "Which demo do you want to run? Type to search",
source: (input: string | undefined) => search(input ?? ""),
initialValue: query,
pageSize: 20,