fix(release): retain npm duplicate-version fallback

This commit is contained in:
Victor Araújo
2026-07-21 14:09:11 -03:00
parent 91443501fb
commit 9169a70184
2 changed files with 8 additions and 4 deletions
+2 -1
View File
@@ -31,11 +31,12 @@ describe("release publish", () => {
});
});
it("recognizes npm's existing-version machine codes without matching registry prose", () => {
it("recognizes npm's existing-version machine codes and registry-precheck prose", () => {
expect(isVersionAlreadyPublished("npm error code E409\nnpm error Cannot publish over existing version")).toBe(
true,
);
expect(isVersionAlreadyPublished("npm error code EPUBLISHCONFLICT")).toBe(true);
expect(isVersionAlreadyPublished("You cannot publish over the previously published versions: 1.2.3.")).toBe(true);
expect(isVersionAlreadyPublished("cannot publish over the previously published version")).toBe(false);
});
});
+6 -3
View File
@@ -287,11 +287,14 @@ async function packAndPublish(dir: string, name: string): Promise<void> {
}
/**
* npm's stable machine codes for an existing exact version:
* `E409` from a registry conflict and `EPUBLISHCONFLICT` from npm.
* npm's stable machine codes for an existing exact version, plus npm 11's
* registry-precheck prose when it emits no machine code.
*/
export function isVersionAlreadyPublished(output: string): boolean {
return /npm error code (E409|EPUBLISHCONFLICT)\b/i.test(output);
return (
/npm error code (E409|EPUBLISHCONFLICT)\b/i.test(output) ||
/you cannot publish over (?:the )?previously published versions?\b/i.test(output)
);
}
async function publishGeneratedLeafPackage(leaf: GeneratedLeafPackage): Promise<void> {