@@ -370,3 +370,69 @@ t.test('global scoped pkg', async t => {
370
370
created : 'global/node_modules/@npmcli/create-test/bin-file.js' ,
371
371
} )
372
372
} )
373
+ t . test ( 'global scoped pkg - new' , async t => {
374
+ const pkgA1 = createPkg ( {
375
+ localVersion : '1.0.0' ,
376
+ name : '@npmcli/A' ,
377
+ } )
378
+
379
+ const pkgA2 = createPkg ( {
380
+ localVersion : '2.0.0' ,
381
+ name : '@npmcli/A' ,
382
+ } )
383
+
384
+ const pkgB = createPkg ( {
385
+ localVersion : '1.0.0' ,
386
+ name : '@npmcli/B' ,
387
+ } )
388
+
389
+ const pkgBfix = merge ( pkgB . fixtures , {
390
+ node_modules : {
391
+ '@npmcli' : { B : {
392
+ node_modules : {
393
+ '@npmcli' : {
394
+ A : pkgA2 . fixtures . packages [ '@npmcli-A-2.0.0' ] ,
395
+ } } ,
396
+ 'package.json' : { dependencies : { '@npmcli/A' : '2.0.0' } } ,
397
+ } ,
398
+ } ,
399
+ } } )
400
+
401
+ const { chmod, exec, readOutput, binLinks, registry, path } = setup ( t , {
402
+ pkg : [ pkgA2 . pkg , pkgA1 . pkg , pkgB . pkg ] ,
403
+ global : true ,
404
+ testdir : merge ( pkgA1 . fixtures , pkgBfix ) ,
405
+ } )
406
+
407
+ await chmod ( )
408
+ await chmod ( 'global/node_modules/@npmcli/B/node_modules/@npmcli/A/bin-file.js' )
409
+ await binLinks ( )
410
+ await binLinks ( {
411
+ name : '@npmcli/A' ,
412
+ path : '@npmcli/B/node_modules/@npmcli/A' ,
413
+ bin : { A : 'bin-file.js' } ,
414
+ } )
415
+
416
+ await pkgA2 . package ( { registry, path, times : 1 , tarballs : [ ] } )
417
+ await pkgA1 . package ( { registry, path, times : 1 , tarballs : [ ] } )
418
+
419
+ await exec ( {
420
+ args : [ '@npmcli/A@2.0.0' ] ,
421
+ } )
422
+
423
+ t . match ( await readOutput ( '@npmcli-A' ) , {
424
+ value : 'packages-2.0.0' ,
425
+ args : [ ] ,
426
+ created : 'global/node_modules/@npmcli/B/node_modules/@npmcli/A/bin-file.js' ,
427
+ } )
428
+
429
+ await exec ( {
430
+ args : [ '@npmcli/A@1.0.0' ] ,
431
+ } )
432
+
433
+ t . match ( await readOutput ( '@npmcli-A' ) , {
434
+ value : 'local-1.0.0' ,
435
+ args : [ ] ,
436
+ created : 'global/node_modules/@npmcli/A/bin-file.js' ,
437
+ } )
438
+ } )
0 commit comments