@@ -2936,7 +2936,20 @@ t.test('installLinks', (t) => {
29362936} )
29372937
29382938t . only ( 'should preserve exact ranges, missing actual tree' , async ( t ) => {
2939- const Arborist = require ( '../../lib/index.js' )
2939+ const Pacote = require ( 'pacote' )
2940+ const Arborist = t . mock ( '../../lib/arborist' , {
2941+ pacote : {
2942+ ...Pacote ,
2943+ extract : async ( ...args ) => {
2944+ if ( args [ 0 ] . startsWith ( 'gitssh' ) ) {
2945+ // we just want to test that this url is handled properly
2946+ // but its not a real git url we can clone so return early
2947+ return true
2948+ }
2949+ return Pacote . extract ( ...args )
2950+ } ,
2951+ } ,
2952+ } )
29402953 const abbrev = resolve ( __dirname ,
29412954 '../fixtures/registry-mocks/content/abbrev/-/abbrev-1.1.1.tgz' )
29422955 const abbrevTGZ = fs . readFileSync ( abbrev )
@@ -2973,6 +2986,40 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
29732986 } ,
29742987 } )
29752988
2989+ const gitSshPackument = JSON . stringify ( {
2990+ _id : 'gitssh' ,
2991+ _rev : 'lkjadflkjasdf' ,
2992+ name : 'gitssh' ,
2993+ 'dist-tags' : { latest : '1.1.1' } ,
2994+ versions : {
2995+ '1.1.1' : {
2996+ name : 'gitssh' ,
2997+ version : '1.1.1' ,
2998+ dist : {
2999+ // this is a url that `new URL()` cant parse
3000+ // https://github.com/npm/cli/issues/5278
3001+ tarball :
'git+ssh://[email protected] :a/b/c.git#lkjadflkjasdf' , 3002+ } ,
3003+ } ,
3004+ } ,
3005+ } )
3006+
3007+ const notAUrlPackument = JSON . stringify ( {
3008+ _id : 'notaurl' ,
3009+ _rev : 'lkjadflkjasdf' ,
3010+ name : 'notaurl' ,
3011+ 'dist-tags' : { latest : '1.1.1' } ,
3012+ versions : {
3013+ '1.1.1' : {
3014+ name : 'notaurl' ,
3015+ version : '1.1.1' ,
3016+ dist : {
3017+ tarball : 'hey been trying to break this test' ,
3018+ } ,
3019+ } ,
3020+ } ,
3021+ } )
3022+
29763023 t . only ( 'host should not be replaced replaceRegistryHost=never' , async ( t ) => {
29773024 const testdir = t . testdir ( {
29783025 project : {
@@ -2981,6 +3028,8 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
29813028 version : '1.0.0' ,
29823029 dependencies : {
29833030 abbrev : '1.1.1' ,
3031+ gitssh : '1.1.1' ,
3032+ notaurl : '1.1.1' ,
29843033 } ,
29853034 } ) ,
29863035 } ,
@@ -2994,6 +3043,14 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
29943043 . get ( '/abbrev/-/abbrev-1.1.1.tgz' )
29953044 . reply ( 200 , abbrevTGZ )
29963045
3046+ tnock ( t , 'https://registry.github.com' )
3047+ . get ( '/gitssh' )
3048+ . reply ( 200 , gitSshPackument )
3049+
3050+ tnock ( t , 'https://registry.github.com' )
3051+ . get ( '/notaurl' )
3052+ . reply ( 200 , notAUrlPackument )
3053+
29973054 const arb = new Arborist ( {
29983055 path : resolve ( testdir , 'project' ) ,
29993056 registry : 'https://registry.github.com' ,
@@ -3011,6 +3068,8 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
30113068 version : '1.0.0' ,
30123069 dependencies : {
30133070 abbrev : '1.1.1' ,
3071+ gitssh : '1.1.1' ,
3072+ notaurl : '1.1.1' ,
30143073 } ,
30153074 } ) ,
30163075 } ,
@@ -3020,10 +3079,18 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
30203079 . get ( '/abbrev' )
30213080 . reply ( 200 , abbrevPackument )
30223081
3082+ tnock ( t , 'https://registry.github.com' )
3083+ . get ( '/gitssh' )
3084+ . reply ( 200 , gitSshPackument )
3085+
30233086 tnock ( t , 'https://registry.github.com' )
30243087 . get ( '/abbrev/-/abbrev-1.1.1.tgz' )
30253088 . reply ( 200 , abbrevTGZ )
30263089
3090+ tnock ( t , 'https://registry.github.com' )
3091+ . get ( '/notaurl' )
3092+ . reply ( 200 , notAUrlPackument )
3093+
30273094 const arb = new Arborist ( {
30283095 path : resolve ( testdir , 'project' ) ,
30293096 registry : 'https://registry.github.com' ,
@@ -3041,6 +3108,8 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
30413108 version : '1.0.0' ,
30423109 dependencies : {
30433110 abbrev : '1.1.1' ,
3111+ gitssh : '1.1.1' ,
3112+ notaurl : '1.1.1' ,
30443113 } ,
30453114 } ) ,
30463115 } ,
@@ -3050,10 +3119,18 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
30503119 . get ( '/abbrev' )
30513120 . reply ( 200 , abbrevPackument2 )
30523121
3122+ tnock ( t , 'https://registry.github.com' )
3123+ . get ( '/gitssh' )
3124+ . reply ( 200 , gitSshPackument )
3125+
30533126 tnock ( t , 'https://registry.github.com' )
30543127 . get ( '/abbrev/-/abbrev-1.1.1.tgz' )
30553128 . reply ( 200 , abbrevTGZ )
30563129
3130+ tnock ( t , 'https://registry.github.com' )
3131+ . get ( '/notaurl' )
3132+ . reply ( 200 , notAUrlPackument )
3133+
30573134 const arb = new Arborist ( {
30583135 path : resolve ( testdir , 'project' ) ,
30593136 registry : 'https://registry.github.com' ,
0 commit comments