Skip to content

Commit 371410d

Browse files
committed
support otp in post publish
1 parent 5316a76 commit 371410d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

build/post-publish.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
const cp = require('child_process');
77
const path = require('path');
88
const fs = require('fs');
9+
const readline = require('readline');
910
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
1011

1112
function updateNextTag() {
@@ -23,11 +24,17 @@ function updateNextTag() {
2324

2425
console.log(name + ": set 'next' tag to latest version");
2526

26-
const result = cp.spawnSync(npm, ['dist-tags', 'add', name + '@' + version, 'next'], opts);
27+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
2728

28-
if (result.error || result.status !== 0) {
29-
process.exit(1);
30-
}
29+
rl.question('Enter OTP token: ', (token) => {
30+
const result = cp.spawnSync(npm, ['--otp', token, 'dist-tags', 'add', name + '@' + version, 'next'], opts);
31+
32+
rl.close();
33+
34+
if (result.error || result.status !== 0) {
35+
process.exit(1);
36+
}
37+
});
3138
}
3239

3340
updateNextTag();

0 commit comments

Comments
 (0)