@@ -259,6 +259,64 @@ t.test('link pkg already in global space', (t) => {
259
259
} )
260
260
} )
261
261
262
+ t . test ( 'link pkg already in global space when prefix is a symlink' , ( t ) => {
263
+ t . plan ( 3 )
264
+
265
+ const testdir = t . testdir ( {
266
+ 'global-prefix' : t . fixture ( 'symlink' , './real-global-prefix' ) ,
267
+ 'real-global-prefix' : {
268
+ lib : {
269
+ node_modules : {
270
+ '@myscope' : {
271
+ linked : t . fixture ( 'symlink' , '../../../../scoped-linked' ) ,
272
+ } ,
273
+ } ,
274
+ } ,
275
+ } ,
276
+ 'scoped-linked' : {
277
+ 'package.json' : JSON . stringify ( {
278
+ name : '@myscope/linked' ,
279
+ version : '1.0.0' ,
280
+ } ) ,
281
+ } ,
282
+ 'my-project' : {
283
+ 'package.json' : JSON . stringify ( {
284
+ name : 'my-project' ,
285
+ version : '1.0.0' ,
286
+ } ) ,
287
+ } ,
288
+ } )
289
+ npm . globalDir = resolve ( testdir , 'global-prefix' , 'lib' , 'node_modules' )
290
+ npm . prefix = resolve ( testdir , 'my-project' )
291
+
292
+ npm . config . find = ( ) => 'default'
293
+
294
+ const _cwd = process . cwd ( )
295
+ process . chdir ( npm . prefix )
296
+
297
+ reifyOutput = async ( ) => {
298
+ reifyOutput = undefined
299
+ process . chdir ( _cwd )
300
+ npm . config . find = ( ) => null
301
+
302
+ const links = await printLinks ( {
303
+ path : npm . prefix ,
304
+ } )
305
+
306
+ t . equal (
307
+ require ( resolve ( testdir , 'my-project' , 'package.json' ) ) . dependencies ,
308
+ undefined ,
309
+ 'should not save to package.json upon linking'
310
+ )
311
+
312
+ t . matchSnapshot ( links , 'should create a local symlink to global pkg' )
313
+ }
314
+
315
+ link ( [ '@myscope/linked' ] , ( err ) => {
316
+ t . ifError ( err , 'should not error out' )
317
+ } )
318
+ } )
319
+
262
320
t . test ( 'completion' , ( t ) => {
263
321
const testdir = t . testdir ( {
264
322
'global-prefix' : {
0 commit comments