Skip to content

Commit 0e6c1d5

Browse files
authored
Enter OTP via enquirer (#12528)
1 parent 67edeea commit 0e6c1d5

File tree

3 files changed

+376
-583
lines changed

3 files changed

+376
-583
lines changed

scripts/release/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
},
77
"dependencies": {
88
"chalk": "4.1.2",
9+
"enquirer": "2.3.6",
910
"execa": "6.1.0",
1011
"minimist": "1.2.5",
1112
"node-fetch": "3.2.3",

scripts/release/steps/publish-to-npm.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import chalk from "chalk";
22
import outdent from "outdent";
33
import { execa } from "execa";
44
import semver from "semver";
5+
import enquirer from "enquirer";
56
import {
67
getBlogPostInfo,
78
getChangelogContent,
@@ -15,11 +16,14 @@ const outdentString = outdent.string;
1516
* Retry "npm publish" when to enter OTP is failed.
1617
*/
1718
async function retryNpmPublish() {
18-
const runNpmPublish = () =>
19-
execa("npm", ["publish"], {
20-
cwd: "./dist",
21-
stdio: "inherit", // we need to input OTP if 2FA enabled
19+
const runNpmPublish = async () => {
20+
const { otp } = await enquirer.prompt({
21+
type: "input",
22+
name: "otp",
23+
message: "Please enter your npm OTP",
2224
});
25+
await execa("npm", ["publish", "--otp", otp], { cwd: "./dist" });
26+
};
2327
for (let i = 5; i > 0; i--) {
2428
try {
2529
return await runNpmPublish();

0 commit comments

Comments
 (0)