UNPKG

backend-smith

Version:

A CLI tool for automating backend component generation in Express.js, including modules, schemas, routes, services, and more.

17 lines (16 loc) 622 B
import fs from 'fs'; import path from "path"; import logger from "../lib/logger"; import { getAbsolutePath } from "./getAbsolutePath"; import { runCommandHelper } from "./runCommandHelper"; export const createFileHepler = (module: string, type: string, content: string) => { const folderPath = getAbsolutePath(module) const filePath = path.join(folderPath, `${module}.${type}.ts`); if (!fs.existsSync(filePath)) { fs.writeFileSync(filePath, content); logger.info(`Created ${type}`); runCommandHelper(`npx prettier ${folderPath} -w`); } else { logger.warn(`File already exists: ${filePath}`); } }