snippeteer/lib/index.ts
2020-05-07 18:40:35 +02:00

29 lines
833 B
TypeScript

/*
* Copyright (C) SapphireCode - All Rights Reserved
* This file is part of Snippeteer which is released under BSD-3-Clause.
* See file 'LICENSE' for full license details.
* Created by Timo Hocker <timo@scode.ovh>, May 2020
*/
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 ());
}) ()
// eslint-disable-next-line no-console
.catch ((e) => console.log (e));