@@ -2,19 +2,13 @@ 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" ;
65
76export class PacoteService implements IPacoteService {
8- private npmConfig : { [ index : string ] : any } = { } ;
9-
107 constructor ( private $fs : IFileSystem ,
118 private $injector : IInjector ,
129 private $logger : ILogger ,
10+ private $npmConfigService : INpmConfigService ,
1311 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- } ) ;
1812 }
1913
2014 @cache ( )
@@ -33,7 +27,9 @@ export class PacoteService implements IPacoteService {
3327
3428 packageName = this . getRealPackageName ( packageName ) ;
3529 this . $logger . trace ( `Calling pacote.manifest for packageName: ${ packageName } and options: ${ JSON . stringify ( manifestOptions , null , 2 ) } ` ) ;
36- return pacote . manifest ( packageName , manifestOptions ) ;
30+ const result = pacote . manifest ( packageName , manifestOptions ) ;
31+
32+ return result ;
3733 }
3834
3935 public async extractPackage ( packageName : string , destinationDirectory : string , options ?: IPacoteExtractOptions ) : Promise < void > {
@@ -78,7 +74,8 @@ export class PacoteService implements IPacoteService {
7874 const cachePath = await this . $packageManager . getCachePath ( ) ;
7975
8076 // Add NPM Configuration to our Manifest options
81- const pacoteOptions = _ . extend ( this . npmConfig , { cache : cachePath } ) ;
77+ const npmConfig = this . $npmConfigService . getConfig ( ) ;
78+ const pacoteOptions = _ . extend ( npmConfig , { cache : cachePath } ) ;
8279 const proxySettings = await this . $proxyService . getCache ( ) ;
8380 if ( proxySettings ) {
8481 _ . extend ( pacoteOptions , proxySettings ) ;
0 commit comments