@@ -657,6 +657,28 @@ test('gitignore option and suppressErrors option', async t => {
657657 t . truthy ( result . includes ( 'bar' ) ) ;
658658} ) ;
659659
660+ test ( 'suppressErrors option with file patterns (issue #166)' , async t => {
661+ const temporary = temporaryDirectory ( ) ;
662+ fs . writeFileSync ( path . join ( temporary , 'validFile.txt' ) , 'test content' , 'utf8' ) ;
663+
664+ // Without suppressErrors, should throw when trying to treat file as directory
665+ await t . throwsAsync (
666+ globby ( [ 'validFile.txt' , 'validFile.txt/**/*.txt' ] , { cwd : temporary } ) ,
667+ { code : 'ENOTDIR' } ,
668+ ) ;
669+ t . throws (
670+ ( ) => globbySync ( [ 'validFile.txt' , 'validFile.txt/**/*.txt' ] , { cwd : temporary } ) ,
671+ { code : 'ENOTDIR' } ,
672+ ) ;
673+
674+ // With suppressErrors, should return the valid file and suppress the error
675+ const asyncResult = await runGlobby ( t , [ 'validFile.txt' , 'validFile.txt/**/*.txt' ] , {
676+ cwd : temporary ,
677+ suppressErrors : true ,
678+ } ) ;
679+ t . deepEqual ( asyncResult , [ 'validFile.txt' ] ) ;
680+ } ) ;
681+
660682test ( 'nested gitignore with negation applies recursively to globby results (issue #255)' , async t => {
661683 const cwd = path . join ( PROJECT_ROOT , 'fixtures' , 'gitignore-negation-nested' ) ;
662684 const result = await runGlobby ( t , '**/*.txt' , { cwd, gitignore : true } ) ;
0 commit comments