mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:30:45 +00:00
fix(update): prune stale compile cache on install
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
createBundledRuntimeDependencyInstallEnv,
|
||||
createNestedNpmInstallEnv,
|
||||
isDirectPostinstallInvocation,
|
||||
pruneOpenClawCompileCache,
|
||||
pruneInstalledPackageDist,
|
||||
discoverBundledPluginRuntimeDeps,
|
||||
pruneBundledPluginSourceNodeModules,
|
||||
@@ -180,6 +181,31 @@ describe("bundled plugin postinstall", () => {
|
||||
expect(spawnSync).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("prunes OpenClaw compile cache during package postinstall", () => {
|
||||
const removed: string[] = [];
|
||||
const existsSync = vi.fn((value: string) =>
|
||||
value.endsWith(path.join("openclaw-cache", "openclaw")),
|
||||
);
|
||||
const rmSync = vi.fn((value: string) => {
|
||||
removed.push(value);
|
||||
});
|
||||
|
||||
pruneOpenClawCompileCache({
|
||||
env: { NODE_COMPILE_CACHE: path.join("/tmp", "openclaw-cache") },
|
||||
existsSync,
|
||||
rmSync,
|
||||
log: { warn: vi.fn() },
|
||||
});
|
||||
|
||||
expect(removed).toEqual([path.join("/tmp", "openclaw-cache", "openclaw")]);
|
||||
expect(rmSync).toHaveBeenCalledWith(path.join("/tmp", "openclaw-cache", "openclaw"), {
|
||||
recursive: true,
|
||||
force: true,
|
||||
maxRetries: 2,
|
||||
retryDelay: 100,
|
||||
});
|
||||
});
|
||||
|
||||
it("prunes source-checkout bundled plugin node_modules", async () => {
|
||||
const packageRoot = await createTempDirAsync("openclaw-source-checkout-");
|
||||
const extensionsDir = path.join(packageRoot, "extensions");
|
||||
|
||||
Reference in New Issue
Block a user