Retry with fresh otp if publish fails (#20582)

Currently, if publishing a package fails, the script crashes, and the
user must start it again from the beginning. Usually this happens
because the one-time password has timed out.

With this change, the user will be prompted for a fresh otp, and the
script will resume publishing.
This commit is contained in:
Andrew Clark
2021-01-13 11:54:56 -08:00
committed by GitHub
parent 405d727dd1
commit 9c48d91686
+16 -2
View File
@@ -48,8 +48,22 @@ const run = async () => {
await confirmVersionAndTags(params);
await validateSkipPackages(params);
await checkNPMPermissions(params);
const otp = await promptForOTP(params);
await publishToNPM(params, otp);
while (true) {
try {
const otp = await promptForOTP(params);
await publishToNPM(params, otp);
break;
} catch (error) {
console.error(error.message);
console.log();
console.log(
theme.error`Publish failed. Enter a fresh otp code to retry.`
);
continue;
}
}
await updateStableVersionNumbers(params);
await printFollowUpInstructions(params);
} catch (error) {