1
1
const path = require ( 'path' ) ;
2
2
const execa = require ( 'execa' ) ;
3
+ const fetch = require ( 'node-fetch' ) ;
3
4
const getRegistry = require ( './get-registry' ) ;
4
5
const getReleaseInfo = require ( './get-release-info' ) ;
5
6
6
- module . exports = async ( { npmPublish, pkgRoot} , pkg , context ) => {
7
+ module . exports = async ( { npmPublish, pkgRoot, otpUrl } , pkg , context ) => {
7
8
const {
8
9
cwd,
9
10
env,
@@ -16,9 +17,14 @@ module.exports = async ({npmPublish, pkgRoot}, pkg, context) => {
16
17
if ( npmPublish !== false && pkg . private !== true ) {
17
18
const basePath = pkgRoot ? path . resolve ( cwd , pkgRoot ) : cwd ;
18
19
const registry = getRegistry ( pkg , context ) ;
20
+ let otpArgs = [ ] ;
21
+ if ( otpUrl ) {
22
+ const res = await fetch ( otpUrl ) ;
23
+ otpArgs = [ '--otp' , await res . text ( ) ] ;
24
+ }
19
25
20
26
logger . log ( 'Publishing version %s to npm registry' , version ) ;
21
- const result = execa ( 'npm' , [ 'publish' , basePath , '--registry' , registry ] , { cwd, env} ) ;
27
+ const result = execa ( 'npm' , [ 'publish' , basePath , '--registry' , registry , ... otpArgs ] , { cwd, env} ) ;
22
28
result . stdout . pipe (
23
29
stdout ,
24
30
{ end : false }
0 commit comments