@@ -4,6 +4,7 @@ import path from 'node:path';
44import util from 'node:util' ;
55import test from 'ava' ;
66import getStream from 'get-stream' ;
7+ import { temporaryDirectory } from 'tempy' ;
78import {
89 globby ,
910 globbySync ,
@@ -261,6 +262,19 @@ test('gitignore option and objectMode option', async t => {
261262 t . truthy ( result [ 0 ] . path ) ;
262263} ) ;
263264
265+ test ( 'gitignore option and suppressErrors option' , async t => {
266+ const temporary = temporaryDirectory ( ) ;
267+ fs . mkdirSync ( path . join ( temporary , 'foo' ) ) ;
268+ fs . writeFileSync ( path . join ( temporary , '.gitignore' ) , 'baz' , 'utf8' ) ;
269+ fs . writeFileSync ( path . join ( temporary , 'bar' ) , '' , 'utf8' ) ;
270+ fs . writeFileSync ( path . join ( temporary , 'baz' ) , '' , 'utf8' ) ;
271+ // Block access to "foo", which should be silently ignored.
272+ fs . chmodSync ( path . join ( temporary , 'foo' ) , 0o000 ) ;
273+ const result = await runGlobby ( t , '**/*' , { cwd : temporary , gitignore : true , suppressErrors : true } ) ;
274+ t . is ( result . length , 1 ) ;
275+ t . truthy ( result . includes ( 'bar' ) ) ;
276+ } ) ;
277+
264278test ( 'respects ignoreFiles string option' , async t => {
265279 const actual = await runGlobby ( t , '*' , { gitignore : false , ignoreFiles : '.gitignore' , onlyFiles : false } ) ;
266280 t . false ( actual . includes ( 'node_modules' ) ) ;
0 commit comments