-
Notifications
You must be signed in to change notification settings - Fork 110
/
add-channel.js
51 lines (44 loc) · 1.22 KB
/
add-channel.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const execa = require('execa');
const getRegistry = require('./get-registry');
const getChannel = require('./get-channel');
const getReleaseInfo = require('./get-release-info');
module.exports = async (npmrc, {npmPublish}, pkg, context) => {
const {
cwd,
env,
stdout,
stderr,
nextRelease: {version, channel},
logger,
} = context;
if (npmPublish !== false && pkg.private !== true) {
const registry = getRegistry(pkg, context);
const distTag = getChannel(channel);
logger.log(`Adding version ${version} to npm registry on dist-tag ${distTag}`);
const result = execa(
'npm',
['dist-tag', 'add', `${pkg.name}@${version}`, distTag, '--userconfig', npmrc, '--registry', registry],
{
cwd,
env,
}
);
result.stdout.pipe(
stdout,
{end: false}
);
result.stderr.pipe(
stderr,
{end: false}
);
await result;
logger.log(`Published ${pkg.name}@${version} on ${registry}`);
return getReleaseInfo(pkg, context, distTag, registry);
}
logger.log(
`Skip adding to npm channel as ${
npmPublish === false ? 'npmPublish' : "package.json's private property"
} is ${npmPublish !== false}`
);
return false;
};