UNPKG

@mongez/gnz

Version:

Generator Z, the next generation of scaffolding tools.

13 lines (12 loc) 1.06 kB
import {ensureDirectory,fileExists,putFile}from'@mongez/fs';import chalk from'chalk';import path from'path';import {namesFactory}from'../../../factories/names-factory.js';import'os';import'eslint';import'prettier';import {throwIf}from'../../../utils/throw-if.js';import {gnWarlockHandler}from'./template.js';const generate = async (options) => { const now = Date.now(); options.fileName ||= namesFactory.controllerFilePath(options.name); options.name = namesFactory.controllerName(options.name); const { name, saveTo } = options; ensureDirectory(saveTo); const Path = path.join(saveTo, `${options.fileName}.ts`); throwIf(fileExists(Path), ` ${chalk.green(options.fileName)}.ts already exists in ${chalk.yellow(saveTo)}`); const content = await gnWarlockHandler(options); putFile(Path, content); console.log(` ${chalk.green(name)} handler has been generated successfully in ${chalk.cyan(saveTo + "/" + options.fileName)} ${chalk.gray(`(${Date.now() - now}ms)`)}`); };export{generate};//# sourceMappingURL=generator.js.map