33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
const repoRoot = process.cwd();
|
|
const distRoot = path.join(repoRoot, "dist");
|
|
const staticDirs = ["assets", "css", "js"];
|
|
|
|
function copyDir(source, destination) {
|
|
fs.rmSync(destination, { recursive: true, force: true });
|
|
fs.mkdirSync(path.dirname(destination), { recursive: true });
|
|
fs.cpSync(source, destination, { recursive: true });
|
|
}
|
|
|
|
for (const dir of staticDirs) {
|
|
copyDir(path.join(repoRoot, dir), path.join(distRoot, dir));
|
|
}
|
|
|
|
const speechIndexSource = path.join(distRoot, "speeches.html");
|
|
const speechIndexDestination = path.join(distRoot, "speeches", "index.html");
|
|
const adminIndexSource = path.join(distRoot, "admin.html");
|
|
const adminIndexDestination = path.join(distRoot, "admin", "index.html");
|
|
|
|
if (fs.existsSync(speechIndexSource)) {
|
|
fs.mkdirSync(path.dirname(speechIndexDestination), { recursive: true });
|
|
fs.copyFileSync(speechIndexSource, speechIndexDestination);
|
|
}
|
|
|
|
if (fs.existsSync(adminIndexSource)) {
|
|
fs.mkdirSync(path.dirname(adminIndexDestination), { recursive: true });
|
|
fs.copyFileSync(adminIndexSource, adminIndexDestination);
|
|
}
|
|
|
|
console.log(`Copied ${staticDirs.join(", ")} into dist/.`);
|