11const path = require ( 'path' ) ;
22const execa = require ( 'execa' ) ;
3+ const fetch = require ( 'node-fetch' ) ;
34const getRegistry = require ( './get-registry' ) ;
45const getReleaseInfo = require ( './get-release-info' ) ;
56
6- module . exports = async ( { npmPublish, pkgRoot} , pkg , context ) => {
7+ module . exports = async ( { npmPublish, pkgRoot, otpUrl } , pkg , context ) => {
78 const {
89 cwd,
910 env,
@@ -16,9 +17,14 @@ module.exports = async ({npmPublish, pkgRoot}, pkg, context) => {
1617 if ( npmPublish !== false && pkg . private !== true ) {
1718 const basePath = pkgRoot ? path . resolve ( cwd , pkgRoot ) : cwd ;
1819 const registry = getRegistry ( pkg , context ) ;
20+ let otpArgs = [ ] ;
21+ if ( otpUrl ) {
22+ const res = await fetch ( otpUrl ) ;
23+ otpArgs = [ '--otp' , await res . text ( ) ] ;
24+ }
1925
2026 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} ) ;
2228 result . stdout . pipe (
2329 stdout ,
2430 { end : false }
0 commit comments