Skip to content

Commit 7cda58c

Browse files
committed
fix(package): keep artifact duplicate diagnostics relative
1 parent 5c0b99a commit 7cda58c

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

scripts/resolve-openclaw-package-candidate.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,11 @@ async function findSingleTarball(dir) {
421421
if (entry.isFile() && /\.t(?:ar\.)?gz$/u.test(entry.name)) {
422422
tarballs.push(absolute);
423423
if (tarballs.length > 1) {
424+
const relativeTarballs = tarballs
425+
.map((tarball) => path.relative(root, tarball))
426+
.toSorted((a, b) => a.localeCompare(b));
424427
throw new Error(
425-
`source=artifact requires exactly one .tgz under ${dir}; found at least 2: ${tarballs.toSorted((a, b) => a.localeCompare(b)).join(", ")}`,
428+
`source=artifact requires exactly one .tgz under ${dir}; found at least 2: ${relativeTarballs.join(", ")}`,
426429
);
427430
}
428431
}

test/scripts/resolve-openclaw-package-candidate.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,9 +990,14 @@ describe("resolve-openclaw-package-candidate", () => {
990990
await writeFile(path.join(dir, "openclaw-a.tgz"), "a");
991991
await writeFile(path.join(dir, "nested.tar.gz"), "b");
992992

993-
await expect(findSingleTarballForTest(dir)).rejects.toThrow(
994-
"source=artifact requires exactly one .tgz",
995-
);
993+
const error = await findSingleTarballForTest(dir).catch((caught: unknown) => caught);
994+
expect(error).toBeInstanceOf(Error);
995+
const message = (error as Error).message;
996+
expect(message).toContain("source=artifact requires exactly one .tgz");
997+
expect(message).toContain("nested.tar.gz");
998+
expect(message).toContain("openclaw-a.tgz");
999+
expect(message).not.toContain(path.join(dir, "nested.tar.gz"));
1000+
expect(message).not.toContain(path.join(dir, "openclaw-a.tgz"));
9961001
});
9971002

9981003
it("reads the source SHA from packed npm build metadata", async () => {

0 commit comments

Comments
 (0)