


















@@ -1,3 +1,4 @@
1+import { readFileSync as readFileSyncOriginal } from "node:fs";
12import fs from "node:fs/promises";
23import { tmpdir } from "node:os";
34import path from "node:path";
@@ -402,6 +403,34 @@ describe("bundled plugin postinstall", () => {
402403await expect(fs.stat(staleFile)).rejects.toMatchObject({ code: "ENOENT" });
403404});
404405406+it("does not abort dist pruning when a listed chunk disappears before import expansion", async () => {
407+const packageRoot = await createTempDirAsync("openclaw-packaged-install-missing-chunk-");
408+const entryFile = path.join(packageRoot, "dist", "control-ui", "assets", "instances.js");
409+const staleFile = path.join(packageRoot, "dist", "stale.js");
410+await fs.mkdir(path.dirname(entryFile), { recursive: true });
411+await fs.writeFile(entryFile, 'import "./chunk.js";\n');
412+await writePackageDistInventory(packageRoot);
413+await fs.writeFile(staleFile, "export {};\n");
414+const readFileSync = vi.fn((filePath: string | Buffer | URL, options?: BufferEncoding) => {
415+if (String(filePath).endsWith("dist/control-ui/assets/instances.js")) {
416+const error = new Error("missing generated asset") as NodeJS.ErrnoException;
417+error.code = "ENOENT";
418+throw error;
419+}
420+return readFileSyncOriginal(filePath, options);
421+});
422+423+expect(() =>
424+pruneInstalledPackageDist({
425+ packageRoot,
426+ readFileSync,
427+log: { log: vi.fn(), warn: vi.fn() },
428+}),
429+).not.toThrow();
430+431+await expect(fs.stat(staleFile)).rejects.toMatchObject({ code: "ENOENT" });
432+});
433+405434it("prunes stale private QA files without restoring compat sidecars", async () => {
406435const packageRoot = await createTempDirAsync("openclaw-packaged-install-qa-compat-");
407436const currentFile = path.join(packageRoot, "dist", "entry.js");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。