INNER CODE UNIT · TypeScript

topics

dolanmiu/docx · demo/index.ts:41

const topics = new Set(demos.map((demo) => path.dirname(demo)));
// A demo's name runs it, but a topic's name lists its demos, even when one of them has the topic's name.
// Searching for "text/" rather than "text" leaves out the demos of other topics, such as text-boxes
const query = topics.has(term) ? `${term}/` : term;
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",

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…