@@ -2,19 +2,13 @@ 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" ;
6
5
7
6
export class PacoteService implements IPacoteService {
8
- private npmConfig : { [ index : string ] : any } = { } ;
9
-
10
7
constructor ( private $fs : IFileSystem ,
11
8
private $injector : IInjector ,
12
9
private $logger : ILogger ,
10
+ private $npmConfigService : INpmConfigService ,
13
11
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
12
}
19
13
20
14
@cache ( )
@@ -33,7 +27,9 @@ export class PacoteService implements IPacoteService {
33
27
34
28
packageName = this . getRealPackageName ( packageName ) ;
35
29
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 ;
37
33
}
38
34
39
35
public async extractPackage ( packageName : string , destinationDirectory : string , options ?: IPacoteExtractOptions ) : Promise < void > {
@@ -78,7 +74,8 @@ export class PacoteService implements IPacoteService {
78
74
const cachePath = await this . $packageManager . getCachePath ( ) ;
79
75
80
76
// 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 } ) ;
82
79
const proxySettings = await this . $proxyService . getCache ( ) ;
83
80
if ( proxySettings ) {
84
81
_ . extend ( pacoteOptions , proxySettings ) ;
0 commit comments