fix(build): keep tsdown prune best-effort

This commit is contained in:
Ayaan Zaidi
2026-04-08 21:14:45 +05:30
parent 654ad0a1fb
commit 17e6ef4076
2 changed files with 41 additions and 10 deletions

View File

@@ -1,5 +1,9 @@
import { describe, expect, it } from "vitest";
import { resolveTsdownBuildInvocation } from "../../scripts/tsdown-build.mjs";
import fs from "node:fs";
import { describe, expect, it, vi } from "vitest";
import {
pruneSourceCheckoutBundledPluginNodeModules,
resolveTsdownBuildInvocation,
} from "../../scripts/tsdown-build.mjs";
describe("resolveTsdownBuildInvocation", () => {
it("routes Windows tsdown builds through the pnpm runner instead of shell=true", () => {
@@ -30,4 +34,26 @@ describe("resolveTsdownBuildInvocation", () => {
},
});
});
it("keeps source-checkout prune best-effort", () => {
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
const rmSync = vi.spyOn(fs, "rmSync");
rmSync.mockImplementation(() => {
throw new Error("locked");
});
expect(() =>
pruneSourceCheckoutBundledPluginNodeModules({
cwd: process.cwd(),
}),
).not.toThrow();
expect(warn).toHaveBeenCalledWith(
"tsdown: could not prune bundled plugin source node_modules: Error: locked",
);
warn.mockRestore();
rmSync.mockRestore();
});
});