mirror of
https://github.com/zoriya/v10.git
synced 2026-08-05 13:48:14 +00:00
27 lines
782 B
TypeScript
27 lines
782 B
TypeScript
import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
|
|
const root = import.meta.dirname;
|
|
const templatesDir = resolve(root, 'templates');
|
|
const srcDir = resolve(root, 'src');
|
|
|
|
function mirror(dir: string) {
|
|
for (const entry of readdirSync(dir)) {
|
|
const templatePath = resolve(dir, entry);
|
|
const targetPath = resolve(srcDir, templatePath.slice(templatesDir.length + 1));
|
|
|
|
if (statSync(templatePath).isDirectory()) {
|
|
mkdirSync(targetPath, { recursive: true });
|
|
mirror(templatePath);
|
|
continue;
|
|
}
|
|
|
|
if (!existsSync(targetPath)) {
|
|
copyFileSync(templatePath, targetPath);
|
|
console.log(`Created ${targetPath.slice(root.length + 1)}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
mirror(templatesDir);
|