1
1
const t = require ( 'tap' )
2
+ const fs = require ( 'fs' )
2
3
3
4
// delete this so that we don't have configs from the fact that it
4
5
// is being run by 'npm test'
@@ -8,6 +9,8 @@ for (env of Object.keys(process.env).filter(e => /^npm_/.test(e))) {
8
9
9
10
const { resolve } = require ( 'path' )
10
11
12
+ const actualPlatform = process . platform
13
+
11
14
const beWindows = ( ) => {
12
15
Object . defineProperty ( process , 'platform' , {
13
16
value : 'win32' ,
@@ -126,7 +129,7 @@ t.test('npm.load', t => {
126
129
] )
127
130
logs . length = 0
128
131
129
- t . equal ( npm . cache , CACHE , 'cache is cache' )
132
+ t . equal ( resolve ( npm . cache ) , resolve ( CACHE ) , 'cache is cache' )
130
133
const newCache = t . testdir ( )
131
134
npm . cache = newCache
132
135
t . equal ( npm . config . get ( 'cache' ) , newCache , 'cache setter sets config' )
@@ -152,10 +155,10 @@ t.test('npm.load', t => {
152
155
npm . config . set ( 'global' , true )
153
156
t . equal ( npm . prefix , npm . globalPrefix , 'prefix is global prefix after setting global' )
154
157
t . notEqual ( npm . prefix , npm . localPrefix , 'prefix is not local prefix after setting global' )
155
- t . equal ( npm . bin , npm . globalBin , 'bin is global bin after prefix setter ' )
156
- t . notEqual ( npm . bin , npm . localBin , 'bin is not local bin after prefix setter ' )
157
- t . equal ( npm . dir , npm . globalDir , 'dir is global dir after prefix setter ' )
158
- t . notEqual ( npm . dir , npm . localDir , 'dir is not local dir after prefix setter ' )
158
+ t . equal ( npm . bin , npm . globalBin , 'bin is global bin after setting global ' )
159
+ t . notEqual ( npm . bin , npm . localBin , 'bin is not local bin after setting global ' )
160
+ t . equal ( npm . dir , npm . globalDir , 'dir is global dir after setting global ' )
161
+ t . notEqual ( npm . dir , npm . localDir , 'dir is not local dir after setting global ' )
159
162
160
163
npm . prefix = dir + '/new/global/prefix'
161
164
t . equal ( npm . prefix , npm . globalPrefix , 'prefix is global prefix after prefix setter' )
@@ -214,11 +217,14 @@ t.test('npm.load', t => {
214
217
} )
215
218
216
219
t . test ( 'node is a symlink' , t => {
217
- const node = process . platform === 'win32' ? 'node.exe' : 'node'
220
+ const node = actualPlatform === 'win32' ? 'node.exe' : 'node'
218
221
const dir = t . testdir ( {
219
- [ node ] : t . fixture ( 'symlink' , process . execPath ) ,
220
222
'.npmrc' : 'foo = bar'
221
223
} )
224
+
225
+ // create manually to set the 'file' option in windows
226
+ fs . symlinkSync ( process . execPath , resolve ( dir , node ) , 'file' )
227
+
222
228
const PATH = process . env . PATH || process . env . Path
223
229
process . env . PATH = dir
224
230
const { execPath } = process
0 commit comments