@@ -2,12 +2,20 @@ import * as pacote from "pacote";
22import * as tar from "tar" ;
33import * as path from "path" ;
44import { cache } from "../common/decorators" ;
5+ import * as npmconfig from "libnpmconfig" ;
56
67export class PacoteService implements IPacoteService {
8+ private npmConfig : { [ index : string ] : any } = { } ;
9+
710 constructor ( private $fs : IFileSystem ,
811 private $injector : IInjector ,
912 private $logger : ILogger ,
10- private $proxyService : IProxyService ) { }
13+ private $proxyService : IProxyService ) {
14+ npmconfig . read ( ) . forEach ( ( value : any , key : string ) => {
15+ // replace env ${VARS} in strings with the process.env value
16+ this . npmConfig [ key ] = typeof value !== 'string' ? value : value . replace ( / \$ { ( [ ^ } ] + ) } / , ( _ , envVar ) => process . env [ envVar ] ) ;
17+ } ) ;
18+ }
1119
1220 @cache ( )
1321 public get $packageManager ( ) : INodePackageManager {
@@ -18,6 +26,10 @@ export class PacoteService implements IPacoteService {
1826 public async manifest ( packageName : string , options ?: IPacoteManifestOptions ) : Promise < any > {
1927 this . $logger . trace ( `Calling pacoteService.manifest for packageName: '${ packageName } ' and options: ${ options } ` ) ;
2028 const manifestOptions : IPacoteBaseOptions = await this . getPacoteBaseOptions ( ) ;
29+
30+ // Add NPM Configuration to our Manifest options
31+ _ . extend ( manifestOptions , this . npmConfig ) ;
32+
2133 if ( options ) {
2234 _ . extend ( manifestOptions , options ) ;
2335 }
0 commit comments