@@ -4,6 +4,8 @@ import { PacoteService } from '../../lib/services/pacote-service';
4
4
import { LoggerStub } from "../stubs" ;
5
5
import { sandbox , SinonSandbox , SinonStub } from "sinon" ;
6
6
import { EventEmitter } from "events" ;
7
+
8
+ const npmconfig = require ( "libnpmconfig" ) ;
7
9
const pacote = require ( "pacote" ) ;
8
10
const tar = require ( "tar" ) ;
9
11
const path = require ( "path" ) ;
@@ -12,7 +14,7 @@ const npmCachePath = "npmCachePath";
12
14
const packageName = "testPackage" ;
13
15
const fullPath = `/Users/username/${ packageName } ` ;
14
16
const destinationDir = "destinationDir" ;
15
- const defaultPacoteOpts : IPacoteBaseOptions = { cache : npmCachePath } ;
17
+ const defaultPacoteOpts : IPacoteBaseOptions = createPacoteOptions ( { cache : npmCachePath } ) ;
16
18
const errorMessage = "error message" ;
17
19
const proxySettings : IProxySettings = {
18
20
hostname : "hostname" ,
@@ -36,6 +38,14 @@ interface ITestCase extends ITestSetup {
36
38
expectedArgs : any [ ] ;
37
39
}
38
40
41
+ function createPacoteOptions ( options : Object ) : Object {
42
+ npmconfig . read ( ) . forEach ( ( value : any , key : string ) => {
43
+ // replace env ${VARS} in strings with the process.env value
44
+ options [ key ] = typeof value !== 'string' ? value : value . replace ( / \$ { ( [ ^ } ] + ) } / , ( _ , envVar ) => process . env [ envVar ] ) ;
45
+ } ) ;
46
+ return options ;
47
+ }
48
+
39
49
const createTestInjector = ( opts ?: ITestSetup ) : IInjector => {
40
50
opts = opts || { } ;
41
51
0 commit comments