20 lines
524 B
TypeScript
20 lines
524 B
TypeScript
|
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 ());
|
||
|
}) ();
|