-
-
Notifications
You must be signed in to change notification settings - Fork 297
/
publish.js
36 lines (27 loc) · 757 Bytes
/
publish.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {execa} from 'execa';
export const getPackagePublishArguments = options => {
const arguments_ = ['publish'];
if (options.contents) {
arguments_.push(options.contents);
}
if (options.tag) {
arguments_.push('--tag', options.tag);
}
if (options.otp) {
arguments_.push('--otp', options.otp);
}
if (options.publishScoped) {
arguments_.push('--access', 'public');
}
return arguments_;
};
export function runPublish(arguments_) {
const cp = execa(...arguments_);
cp.stdout.on('data', chunk => {
// https://github.com/yarnpkg/berry/blob/a3e5695186f2aec3a68810acafc6c9b1e45191da/packages/plugin-npm/sources/npmHttpUtils.ts#L541
if (chunk.toString('utf8').includes('One-time password:')) {
cp.kill();
}
});
return cp;
}