UNPKG

constatic

Version:

Constatic is a CLI for creating and managing modern TypeScript projects, providing an organized structure and features that streamline development.

19 lines (18 loc) 619 B
// src/shared/presets/scripts/apply.ts import merge from "lodash.merge"; import path from "node:path"; import { copy } from "#helpers"; async function applyScriptPresets(cli, props) { const { dist, presets, pkg } = props; const promises = []; for (const script of presets) { if (pkg && script.packageJson) { merge(pkg, script.packageJson); } promises.push(...script.files.map((file) => copy(path.join(cli.config.dirname, "presets/scripts", script.id, file.path), path.join(dist, file.dist ?? file.path)))); } await Promise.all(promises).catch(() => null); } export { applyScriptPresets };