about summary refs log tree commit diff stats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/build.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/build.ts b/bin/build.ts
new file mode 100755
index 0000000..d6b6df9
--- /dev/null
+++ b/bin/build.ts
@@ -0,0 +1,30 @@
+#!/usr/bin/env bun
+import fs from "node:fs";
+import log from "loglevel";
+
+import generateSite from "../src/templates";
+
+log.setLevel((Bun.env.LOG_LEVEL || "info") as log.LogLevelDesc);
+
+fs.mkdirSync("public", { recursive: true });
+log.info("Generating site...");
+try {
+  await generateSite();
+} catch (error) {
+  log.error("Error generating site", error);
+  process.exit(1);
+}
+
+log.info("Copying static files...");
+if (!fs.existsSync("static")) {
+  log.error("static directory not found");
+  process.exit(1);
+}
+fs.readdirSync("static").map((file) => {
+  log.info(`Copying static/${file}`);
+  fs.cpSync(`static/${file}`, `public/${file}`, {
+    dereference: true,
+    recursive: true,
+    preserveTimestamps: true,
+  });
+});