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