@yanhe-su/cli
Version:
CLI tool for DAO Style projects - providing project scaffolding, template generation and dependency management
21 lines (20 loc) • 630 B
JavaScript
import * as path from 'path';
import fs from 'fs-extra';
import { renderTemplate } from './template';
export async function fileExists(filePath) {
try {
await fs.access(filePath);
return true;
}
catch {
return false;
}
}
export async function createDirectory(dirPath) {
await fs.ensureDir(dirPath);
}
export async function copyTemplate(templatePath, targetPath, data = {}) {
const content = await fs.readFile(templatePath, 'utf-8');
const rendered = await renderTemplate(content, data, path.dirname(templatePath), templatePath);
await fs.outputFile(targetPath, rendered);
}