Skip to content

Commit

Permalink
fix(release): catch 403 when publishing an existing version (#20155)
Browse files Browse the repository at this point in the history
  • Loading branch information
fahslaj authored Nov 10, 2023
1 parent c04fa3a commit 0af7ad4
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,17 @@ export default async function runExecutor(

const stdoutData = JSON.parse(err.stdout?.toString() || '{}');
if (
// handle npm conflict error
stdoutData.error?.code === 'EPUBLISHCONFLICT' ||
// handle npm conflict error when the package has a scope
(stdoutData.error?.code === 'E403' &&
stdoutData.error?.body?.error?.includes(
stdoutData.error?.summary?.includes(
'You cannot publish over the previously published versions'
)) ||
// handle verdaccio conflict error
(stdoutData.error?.code === 'E409' &&
stdoutData.error?.summary?.includes(
'this package is already present'
))
) {
console.warn(
Expand All @@ -123,6 +130,11 @@ export default async function runExecutor(
if (stdoutData.error.detail) {
console.error(stdoutData.error.detail);
}

if (context.isVerbose) {
console.error('npm publish stdout:');
console.error(JSON.stringify(stdoutData, null, 2));
}
return {
success: false,
};
Expand Down

0 comments on commit 0af7ad4

Please sign in to comment.