Skip to content

Commit 9b98ab1

Browse files
committed
perf(build): clean cached resources before build to ensure freshness
Remove cached resources for the current version to prevent stale data from being used in the build process
1 parent 6329419 commit 9b98ab1

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

scripts/build.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bun
22
import '../src/shared/runtime/suppress-baseline-warning.js';
3-
import { mkdirSync, rmSync, cpSync, readFileSync, writeFileSync, readdirSync } from 'node:fs';
3+
import { mkdirSync, rmSync, cpSync, readFileSync, writeFileSync, readdirSync, existsSync } from 'node:fs';
44
import { join, dirname, resolve, relative } from 'node:path';
55
import { fileURLToPath } from 'node:url';
6-
import { platform, arch } from 'node:os';
6+
import { platform, arch, homedir } from 'node:os';
77
import { $ } from 'bun';
88

99
// Simple ANSI colors
@@ -43,6 +43,13 @@ console.log(`\n${bold}${cyan}╭────────────────
4343
console.log(`${bold}${cyan}${reset} Building ${bold}CodeMachine${reset} v${mainVersion} ${bold}${cyan}${reset}`);
4444
console.log(`${bold}${cyan}╰────────────────────────────────────────╯${reset}\n`);
4545

46+
// Clean cached resources for this version to ensure fresh extraction on next run
47+
const cachedResourcesDir = join(homedir(), '.codemachine', 'resources', mainVersion);
48+
if (existsSync(cachedResourcesDir)) {
49+
rmSync(cachedResourcesDir, { recursive: true, force: true });
50+
console.log(`${green}${reset} ${dim}Cleaned cached resources at ${cachedResourcesDir}${reset}`);
51+
}
52+
4653
// Collect resource files for embedding and generate a manifest that imports them.
4754
function collectFiles(dir: string): string[] {
4855
const results: string[] = [];

0 commit comments

Comments
 (0)