Skip to content

Commit c9261ac

Browse files
authored
fix(0.78, ci): downgrade npm auth token list check to warning (#2548)
Backport of #2547
1 parent a6cfc75 commit c9261ac

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

.ado/scripts/prepublish-check.mjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ function verifyNpmAuth(registry = NPM_DEFEAULT_REGISTRY) {
103103
if (whoami.status !== 0) {
104104
const error = whoami.stderr.toString();
105105
const m = error.match(npmErrorRegex);
106-
switch (m && m[1]) {
106+
const errorCode = m && m[1];
107+
switch (errorCode) {
107108
case "EINVALIDNPMTOKEN":
108109
throw new Error(`Invalid auth token for npm registry: ${registry}`);
109110
case "ENEEDAUTH":
@@ -118,7 +119,15 @@ function verifyNpmAuth(registry = NPM_DEFEAULT_REGISTRY) {
118119
if (token.status !== 0) {
119120
const error = token.stderr.toString();
120121
const m = error.match(npmErrorRegex);
121-
throw new Error(m ? `Auth token for '${registry}' returned error code ${m[1]}` : error);
122+
const errorCode = m && m[1];
123+
124+
// E403 means the token doesn't have permission to list tokens, but that's
125+
// not required for publishing. Only fail for other error codes.
126+
if (errorCode === "E403") {
127+
info(`Token verification skipped: token doesn't have permission to list tokens (${errorCode})`);
128+
} else {
129+
throw new Error(m ? `Auth token for '${registry}' returned error code ${errorCode}` : error);
130+
}
122131
}
123132
}
124133

0 commit comments

Comments
 (0)