@@ -2,12 +2,20 @@ import * as pacote from "pacote";
2
2
import * as tar from "tar" ;
3
3
import * as path from "path" ;
4
4
import { cache } from "../common/decorators" ;
5
+ import * as npmconfig from "libnpmconfig" ;
5
6
6
7
export class PacoteService implements IPacoteService {
8
+ private npmConfig : { [ index : string ] : any } = { } ;
9
+
7
10
constructor ( private $fs : IFileSystem ,
8
11
private $injector : IInjector ,
9
12
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
+ }
11
19
12
20
@cache ( )
13
21
public get $packageManager ( ) : INodePackageManager {
@@ -18,6 +26,10 @@ export class PacoteService implements IPacoteService {
18
26
public async manifest ( packageName : string , options ?: IPacoteManifestOptions ) : Promise < any > {
19
27
this . $logger . trace ( `Calling pacoteService.manifest for packageName: '${ packageName } ' and options: ${ options } ` ) ;
20
28
const manifestOptions : IPacoteBaseOptions = await this . getPacoteBaseOptions ( ) ;
29
+
30
+ // Add NPM Configuration to our Manifest options
31
+ _ . extend ( manifestOptions , this . npmConfig ) ;
32
+
21
33
if ( options ) {
22
34
_ . extend ( manifestOptions , options ) ;
23
35
}
0 commit comments