UNPKG

@maizzle/framework

Version:

Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.

29 lines (28 loc) 946 B
import color from "picocolors"; import * as p from "@clack/prompts"; import { lstat, mkdir, readFile, writeFile } from "node:fs/promises"; import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import process from "node:process"; //#region src/commands/make/scaffold.ts const __dirname = dirname(fileURLToPath(import.meta.url)); async function scaffold(filePath, stubName) { try { await lstat(filePath); p.outro(color.red(`ERROR: ${filePath} already exists.`)); process.exit(1); } catch { const content = await readFile(resolve(__dirname, `stubs/${stubName}`), "utf-8"); const dir = dirname(filePath); if (!await lstat(dir).catch(() => false)) await mkdir(dir, { recursive: true }); await writeFile(filePath, content); p.outro(`${filePath} has been created.`); process.exit(0); } } function onCancel() { p.cancel("Canceled."); process.exit(0); } //#endregion export { onCancel, scaffold };