snippeteer/lib/index.ts

20 lines
524 B
TypeScript
Raw Normal View History

2020-04-15 20:21:00 +02:00
import path from 'path';
import fs from 'fs-extra';
import { AutoComplete } from 'enquirer';
import { Snippet } from './Snippet';
(async (): Promise<void> => {
const snippets = await fs.readdir (path.join (__dirname, 'snippets'));
const snippet = await new AutoComplete (
{
name: 'snippet',
message: 'choose a snippet',
choices: snippets
}
)
.run ();
const runner
= new (await import (`./snippets/${snippet}/index.js`)).default as Snippet;
runner.start (process.cwd ());
}) ();