siuuuu
Version:
A tool library for automatically generating code based on plop and babel
29 lines (22 loc) • 610 B
text/typescript
import chalk from 'chalk';
import nodePlop from 'node-plop';
import { getPlopFile } from '../../utils/shared.js';
const plopFilePath = getPlopFile(import.meta.url);
const plop = await nodePlop(plopFilePath);
const basicAdd = plop.getGenerator('router');
export default async function (answers: any) {
if (!answers) {
answers = await basicAdd.runPrompts();
}
const res = await basicAdd.runActions(answers);
if (res.failures.length) {
console.log(
chalk.red(
'ERROR when',
res.failures[0].type,
answers.name,
res.failures[0].error
)
);
}
}