mirror of
https://github.com/storytold/spark.git
synced 2026-10-17 00:12:59 +00:00
Copy static files to docs/site directory
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import fs from "node:fs";
|
||||
import { copyFile, mkdir, rename } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
function copyDir(src, dest) {
|
||||
if (!fs.existsSync(dest)) {
|
||||
fs.mkdirSync(dest, { recursive: true });
|
||||
}
|
||||
|
||||
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
||||
const srcPath = path.join(src, entry.name);
|
||||
const destPath = path.join(dest, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
copyDir(srcPath, destPath);
|
||||
} else {
|
||||
fs.copyFileSync(srcPath, destPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy static files to docs directory.
|
||||
copyDir("examples", "docs/examples");
|
||||
await copyFile("examples.html", "docs/examples/index.html");
|
||||
await rename("docs/examples/viewer", "docs/viewer");
|
||||
await mkdir("docs/examples/vendor", { recursive: true });
|
||||
copyDir("node_modules/three", "docs/examples/js/vendor/three");
|
||||
copyDir("dist", "docs/dist");
|
||||
console.log("Site generated in docs directory.");
|
||||
Reference in New Issue
Block a user