-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathpackagePublish.ts
More file actions
33 lines (31 loc) · 888 Bytes
/
packagePublish.ts
File metadata and controls
33 lines (31 loc) · 888 Bytes
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
import { PackageInfo } from '../types/PackageInfo';
import path from 'path';
import { getNpmAuthArgs, npm } from './npm';
import { AuthType } from '../types/Auth';
export function packagePublish(
packageInfo: PackageInfo,
registry: string,
token: string,
access: string,
authType?: AuthType,
timeout?: number | undefined
) {
const packageOptions = packageInfo.combinedOptions;
const packagePath = path.dirname(packageInfo.packageJsonPath);
const args = [
'publish',
'--registry',
registry,
'--tag',
packageOptions.tag || packageOptions.defaultNpmTag,
'--loglevel',
'warn',
...getNpmAuthArgs(registry, token, authType),
];
if (access && packageInfo.name.startsWith('@')) {
args.push('--access');
args.push(access);
}
console.log(`publish command: ${args.join(' ')}`);
return npm(args, { cwd: packagePath, timeout });
}