about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-06-18 14:26:39 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-06-18 14:26:39 +0300
commitaaa40a97005a6323710ad3823532d56b668dd837 (patch)
tree414e450fb2de04224554a38ab9ada6f8e11ab1ff
parentf0b78f6562d109c1f1c76d8bd864ef9a7b1d8852 (diff)
downloadthe-epube-aaa40a97005a6323710ad3823532d56b668dd837.tar.gz
the-epube-aaa40a97005a6323710ad3823532d56b668dd837.tar.xz
cleanup old timestamped files on build
-rw-r--r--build.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/build.js b/build.js
index 3a5f6f8..a2eb419 100644
--- a/build.js
+++ b/build.js
@@ -1,7 +1,7 @@
 #!/usr/bin/env node
 
 import * as esbuild from 'esbuild';
-import { copyFileSync, readFileSync } from 'fs';
+import { copyFileSync, readFileSync, unlinkSync } from 'fs';
 import { writeFile } from 'fs/promises';
 import { globSync } from 'glob';
 import less from 'less';
@@ -98,6 +98,12 @@ async function buildApp() {
 
 	console.log('creating timestamped js files...');
 
+	// remove stale timestamped files from previous builds
+	const oldVersioned = globSync('dist/*_v[0-9]*');
+	for (const f of oldVersioned) {
+		try { unlinkSync(f); } catch { /* ignore */ }
+	}
+
 	// also create suffixed filenames for our worker to determine proper replica (a pseudo-atomic build)
 	const builtFiles = globSync('dist/**/*.js');
 	for (const file of builtFiles) {