@@ -257,9 +257,95 @@ describe('Path Resolve', () => {
257
257
] )
258
258
} )
259
259
260
- it ( 'should respect .gitignore' )
261
- it ( 'should always ignore some paths' )
262
- it ( 'should respect ignore in socket config' )
263
- it ( 'should ignore irrelevant matches' )
260
+ it ( 'should respect ignores from socket config' , async ( ) => {
261
+ mockFs ( {
262
+ '/bar/package-lock.json' : '{}' ,
263
+ '/bar/package.json' : '{}' ,
264
+ '/foo/package-lock.json' : '{}' ,
265
+ '/foo/package.json' : '{}' ,
266
+ } )
267
+
268
+ await getPackageFiles (
269
+ '/' ,
270
+ [ '**/*' ] ,
271
+ {
272
+ version : 2 ,
273
+ projectIgnorePaths : [
274
+ '/bar/*' ,
275
+ '!/bar/package.json' ,
276
+ ]
277
+ } ,
278
+ ( ) => { }
279
+ ) . should . eventually . become ( [
280
+ '/bar/package.json' ,
281
+ '/foo/package.json' ,
282
+ '/foo/package-lock.json' ,
283
+ ] )
284
+ } )
285
+
286
+ it ( 'should respect .gitignore' , async ( ) => {
287
+ mockFs ( {
288
+ '/.gitignore' : '/bar\n!/bar/package.json' ,
289
+ '/bar/package-lock.json' : '{}' ,
290
+ '/bar/package.json' : '{}' ,
291
+ '/foo/package-lock.json' : '{}' ,
292
+ '/foo/package.json' : '{}' ,
293
+ } )
294
+
295
+ await getPackageFiles (
296
+ '/' ,
297
+ [ '**/*' ] ,
298
+ undefined ,
299
+ ( ) => { }
300
+ ) . should . eventually . become ( [
301
+ '/foo/package.json' ,
302
+ '/foo/package-lock.json' ,
303
+ ] )
304
+ } )
305
+
306
+ it ( 'should always ignore some paths' , async ( ) => {
307
+ mockFs ( {
308
+ // Mirrors the used list form https://github.com/novemberborn/ignore-by-default
309
+ '/.git/some/dir/package.json' : { } ,
310
+ '/.log/some/dir/package.json' : { } ,
311
+ '/.nyc_output/some/dir/package.json' : { } ,
312
+ '/.sass-cache/some/dir/package.json' : { } ,
313
+ '/.yarn/some/dir/package.json' : { } ,
314
+ '/bower_components/some/dir/package.json' : { } ,
315
+ '/coverage/some/dir/package.json' : { } ,
316
+ '/node_modules/@socketsecurity/cli/package.json' : '{}' ,
317
+ '/foo/package-lock.json' : '{}' ,
318
+ '/foo/package.json' : '{}' ,
319
+ } )
320
+
321
+ await getPackageFiles (
322
+ '/' ,
323
+ [ '**/*' ] ,
324
+ undefined ,
325
+ ( ) => { }
326
+ ) . should . eventually . become ( [
327
+ '/foo/package.json' ,
328
+ '/foo/package-lock.json' ,
329
+ ] )
330
+ } )
331
+
332
+ it ( 'should ignore irrelevant matches' , async ( ) => {
333
+ mockFs ( {
334
+ '/foo/package-foo.json' : '{}' ,
335
+ '/foo/package-lock.json' : '{}' ,
336
+ '/foo/package.json' : '{}' ,
337
+ '/foo/random.json' : '{}' ,
338
+ } )
339
+
340
+ await getPackageFiles (
341
+ '/' ,
342
+ [ '**/*' ] ,
343
+ undefined ,
344
+ ( ) => { }
345
+ ) . should . eventually . become ( [
346
+ '/foo/package.json' ,
347
+ '/foo/package-lock.json' ,
348
+ ] )
349
+ } )
264
350
} )
265
351
} )
0 commit comments