@@ -2936,7 +2936,20 @@ t.test('installLinks', (t) => {
2936
2936
} )
2937
2937
2938
2938
t . 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
+ } )
2940
2953
const abbrev = resolve ( __dirname ,
2941
2954
'../fixtures/registry-mocks/content/abbrev/-/abbrev-1.1.1.tgz' )
2942
2955
const abbrevTGZ = fs . readFileSync ( abbrev )
@@ -2973,6 +2986,40 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
2973
2986
} ,
2974
2987
} )
2975
2988
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://git@github.com: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
+
2976
3023
t . only ( 'host should not be replaced replaceRegistryHost=never' , async ( t ) => {
2977
3024
const testdir = t . testdir ( {
2978
3025
project : {
@@ -2981,6 +3028,8 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
2981
3028
version : '1.0.0' ,
2982
3029
dependencies : {
2983
3030
abbrev : '1.1.1' ,
3031
+ gitssh : '1.1.1' ,
3032
+ notaurl : '1.1.1' ,
2984
3033
} ,
2985
3034
} ) ,
2986
3035
} ,
@@ -2994,6 +3043,14 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
2994
3043
. get ( '/abbrev/-/abbrev-1.1.1.tgz' )
2995
3044
. reply ( 200 , abbrevTGZ )
2996
3045
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
+
2997
3054
const arb = new Arborist ( {
2998
3055
path : resolve ( testdir , 'project' ) ,
2999
3056
registry : 'https://registry.github.com' ,
@@ -3011,6 +3068,8 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
3011
3068
version : '1.0.0' ,
3012
3069
dependencies : {
3013
3070
abbrev : '1.1.1' ,
3071
+ gitssh : '1.1.1' ,
3072
+ notaurl : '1.1.1' ,
3014
3073
} ,
3015
3074
} ) ,
3016
3075
} ,
@@ -3020,10 +3079,18 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
3020
3079
. get ( '/abbrev' )
3021
3080
. reply ( 200 , abbrevPackument )
3022
3081
3082
+ tnock ( t , 'https://registry.github.com' )
3083
+ . get ( '/gitssh' )
3084
+ . reply ( 200 , gitSshPackument )
3085
+
3023
3086
tnock ( t , 'https://registry.github.com' )
3024
3087
. get ( '/abbrev/-/abbrev-1.1.1.tgz' )
3025
3088
. reply ( 200 , abbrevTGZ )
3026
3089
3090
+ tnock ( t , 'https://registry.github.com' )
3091
+ . get ( '/notaurl' )
3092
+ . reply ( 200 , notAUrlPackument )
3093
+
3027
3094
const arb = new Arborist ( {
3028
3095
path : resolve ( testdir , 'project' ) ,
3029
3096
registry : 'https://registry.github.com' ,
@@ -3041,6 +3108,8 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
3041
3108
version : '1.0.0' ,
3042
3109
dependencies : {
3043
3110
abbrev : '1.1.1' ,
3111
+ gitssh : '1.1.1' ,
3112
+ notaurl : '1.1.1' ,
3044
3113
} ,
3045
3114
} ) ,
3046
3115
} ,
@@ -3050,10 +3119,18 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
3050
3119
. get ( '/abbrev' )
3051
3120
. reply ( 200 , abbrevPackument2 )
3052
3121
3122
+ tnock ( t , 'https://registry.github.com' )
3123
+ . get ( '/gitssh' )
3124
+ . reply ( 200 , gitSshPackument )
3125
+
3053
3126
tnock ( t , 'https://registry.github.com' )
3054
3127
. get ( '/abbrev/-/abbrev-1.1.1.tgz' )
3055
3128
. reply ( 200 , abbrevTGZ )
3056
3129
3130
+ tnock ( t , 'https://registry.github.com' )
3131
+ . get ( '/notaurl' )
3132
+ . reply ( 200 , notAUrlPackument )
3133
+
3057
3134
const arb = new Arborist ( {
3058
3135
path : resolve ( testdir , 'project' ) ,
3059
3136
registry : 'https://registry.github.com' ,
0 commit comments