summaryrefslogtreecommitdiff
path: root/build.ts
diff options
context:
space:
mode:
authorseth <[email protected]>2023-11-12 00:56:18 -0500
committerseth <[email protected]>2023-11-12 00:56:18 -0500
commit2e64b8579fed604306958b89271ad068df2f54ce (patch)
tree2d94cce07b92f68201669a59283ce150e6878a0c /build.ts
parent70edf4c616e59a8e83e7ca7faf9faefd6e0b817c (diff)
fix: route static files correctly
Diffstat (limited to 'build.ts')
-rw-r--r--build.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/build.ts b/build.ts
index 47b13f7..4937cf3 100644
--- a/build.ts
+++ b/build.ts
@@ -4,20 +4,22 @@ import { constants, copyFile, mkdir, readdir, rm } from "node:fs/promises";
import { join } from "node:path";
const distDir = "dist";
+const contentDir = join(distDir, "static");
const teawieArchiveDir = "Teawie-Archive/teawie-media/Original Teawies";
const checkAndCreate = async (dir: string) => {
if (!existsSync(dir)) {
await mkdir(dir, { recursive: true });
+ } else {
+ for (const f of await readdir(dir)) {
+ await rm(join(dir, f), { recursive: true, force: true });
+ }
}
};
await checkAndCreate(distDir);
-for (const f of await readdir(distDir)) {
- await rm(join(distDir, f), { recursive: true, force: true });
-}
-
-await checkAndCreate(join(distDir, "static/teawie"));
+await checkAndCreate(contentDir);
+await checkAndCreate(join(contentDir, "teawie"));
const wies = (await readdir(teawieArchiveDir)).filter((wie) => {
const fileExt = wie.split(".").pop();
@@ -25,7 +27,7 @@ const wies = (await readdir(teawieArchiveDir)).filter((wie) => {
});
for (const f of wies) {
- await copyFile(join(teawieArchiveDir, f), join(distDir, "static/teawie", f), constants.COPYFILE_FICLONE);
+ await copyFile(join(teawieArchiveDir, f), join(contentDir, "teawie", f), constants.COPYFILE_FICLONE);
}
const define = {