@@ -23,6 +23,8 @@ import {
2323const cwd = process . cwd ( ) ;
2424const temporary = 'tmp' ;
2525
26+ const cwdDirectoryError = { message : / T h e ` c w d ` o p t i o n m u s t b e a p a t h t o a d i r e c t o r y , g o t : / } ;
27+
2628const fixture = [
2729 'a.tmp' ,
2830 'b.tmp' ,
@@ -704,29 +706,27 @@ test('`{extension: false}` and `expandDirectories.extensions` option', async t =
704706} ) ;
705707
706708test ( 'throws when specifying a file as cwd' , async t => {
707- const error = { message : 'The `cwd` option must be a path to a directory' } ;
708-
709709 for ( const file of getPathValues ( path . resolve ( 'fixtures/gitignore/bar.js' ) ) ) {
710710 // eslint-disable-next-line no-await-in-loop
711- await t . throwsAsync ( globby ( '.' , { cwd : file } ) , error ) ;
711+ await t . throwsAsync ( globby ( '.' , { cwd : file } ) , cwdDirectoryError ) ;
712712 // eslint-disable-next-line no-await-in-loop
713- await t . throwsAsync ( globby ( '*' , { cwd : file } ) , error ) ;
714- t . throws ( ( ) => globbySync ( '.' , { cwd : file } ) , error ) ;
715- t . throws ( ( ) => globbySync ( '*' , { cwd : file } ) , error ) ;
716- t . throws ( ( ) => globbyStream ( '.' , { cwd : file } ) , error ) ;
717- t . throws ( ( ) => globbyStream ( '*' , { cwd : file } ) , error ) ;
713+ await t . throwsAsync ( globby ( '*' , { cwd : file } ) , cwdDirectoryError ) ;
714+ t . throws ( ( ) => globbySync ( '.' , { cwd : file } ) , cwdDirectoryError ) ;
715+ t . throws ( ( ) => globbySync ( '*' , { cwd : file } ) , cwdDirectoryError ) ;
716+ t . throws ( ( ) => globbyStream ( '.' , { cwd : file } ) , cwdDirectoryError ) ;
717+ t . throws ( ( ) => globbyStream ( '*' , { cwd : file } ) , cwdDirectoryError ) ;
718718 }
719719} ) ;
720720
721721test ( 'throws when specifying a file as cwd - isDynamicPattern' , t => {
722722 for ( const file of getPathValues ( path . resolve ( 'fixtures/gitignore/bar.js' ) ) ) {
723723 t . throws ( ( ) => {
724724 isDynamicPattern ( '.' , { cwd : file } ) ;
725- } , { message : 'The `cwd` option must be a path to a directory' } ) ;
725+ } , cwdDirectoryError ) ;
726726
727727 t . throws ( ( ) => {
728728 isDynamicPattern ( '*' , { cwd : file } ) ;
729- } , { message : 'The `cwd` option must be a path to a directory' } ) ;
729+ } , cwdDirectoryError ) ;
730730 }
731731} ) ;
732732
0 commit comments