/* * 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 , May 2020 */ import path from 'path'; import fs from 'fs-extra'; import { AutoComplete } from 'enquirer'; import { Snippet } from './Snippet'; (async (): Promise => { const snippets = await fs.readdir (path.join (__dirname, 'snippets')); const runners: Record = {}; await Promise.all ( snippets.map (async (s) => { const runner = (new ( await import (`./snippets/${s}/index.js`) ).default) as Snippet; runners[s] = runner; }) ); const snippet = await new AutoComplete ({ name: 'snippet', message: 'choose a snippet', choices: snippets.filter ((s) => runners[s].is_active ()) }) .run (); runners[snippet].start (process.cwd ()); }) () // eslint-disable-next-line no-console .catch ((e) => console.log (e));