Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"type": "module",
"scripts": {
"prepare": "effect-tsgo patch && vp config --no-agent",
"prepare": "node scripts/clean-tsgo-backups.mjs && effect-tsgo patch && vp config --no-agent",
"dev": "node scripts/dev-runner.ts dev",
"dev:share": "node scripts/dev-runner.ts dev --share",
"dev:server": "node scripts/dev-runner.ts dev:server",
Expand Down
24 changes: 24 additions & 0 deletions scripts/clean-tsgo-backups.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Deletes stale tsgo backup files left behind by `effect-tsgo patch`.
//
// The patch command backs up the real tsgo binary to `tsgo.original`, and if
// that name is taken it writes `tsgo.original.1`, `.2`, ... without ever
// cleaning up. On runners that restore node_modules from a build cache
// (Vercel), backups accumulate across deploys until patch hard-fails at 101
// with "Too many backup files exist". Removing them is safe: from the second
// patch onward the backup is just the previously-patched binary, and pnpm
// restores the pristine one whenever the package is re-materialized.
//
// Runs as part of `prepare`, so it must only use node builtins.
import * as NodeFS from "node:fs";

const backups = NodeFS.globSync(
"node_modules/.pnpm/@typescript+native-preview-*/node_modules/@typescript/native-preview-*/lib/tsgo{,.exe}.original*",
);

for (const backup of backups) {
NodeFS.rmSync(backup, { force: true });
}

if (backups.length > 0) {
console.log(`Removed ${backups.length} stale tsgo backup(s)`);
}
Loading