@@ -8,6 +8,7 @@ var sinon = require('sinon');
8
8
var rimraf = require ( 'rimraf' ) ;
9
9
var fs = require ( 'graceful-fs' ) ;
10
10
var sysPath = require ( 'path' ) ;
11
+ var upath = require ( "upath" ) ;
11
12
var cp = require ( 'child_process' ) ;
12
13
chai . use ( require ( 'sinon-chai' ) ) ;
13
14
var os = process . platform ;
@@ -767,6 +768,33 @@ function runTests(baseopts) {
767
768
} ) ;
768
769
} ) ;
769
770
} ) ;
771
+ it ( 'should correctly handle glob with braces' , function ( done ) {
772
+ var spy = sinon . spy ( ) ;
773
+ var watchPath = upath . normalizeSafe ( getFixturePath ( '{subdir/*,subdir1/subsub1}/subsubsub/*.txt' ) ) ;
774
+ var deepFileA = getFixturePath ( 'subdir/subsub/subsubsub/a.txt' ) ;
775
+ var deepFileB = getFixturePath ( 'subdir1/subsub1/subsubsub/a.txt' ) ;
776
+ fs . mkdirSync ( getFixturePath ( 'subdir' ) , 0x1ed ) ;
777
+ fs . mkdirSync ( getFixturePath ( 'subdir/subsub' ) , 0x1ed ) ;
778
+ fs . mkdirSync ( getFixturePath ( 'subdir/subsub/subsubsub' ) , 0x1ed ) ;
779
+ fs . mkdirSync ( getFixturePath ( 'subdir1' ) , 0x1ed ) ;
780
+ fs . mkdirSync ( getFixturePath ( 'subdir1/subsub1' ) , 0x1ed ) ;
781
+ fs . mkdirSync ( getFixturePath ( 'subdir1/subsub1/subsubsub' ) , 0x1ed ) ;
782
+ fs . writeFileSync ( deepFileA , Date . now ( ) ) ;
783
+ fs . writeFileSync ( deepFileB , Date . now ( ) ) ;
784
+ watcher = chokidar . watch ( watchPath , options )
785
+ . on ( 'all' , spy )
786
+ . on ( 'ready' , function ( ) {
787
+ spy . should . have . been . calledWith ( 'add' , deepFileA ) ;
788
+ spy . should . have . been . calledWith ( 'add' , deepFileB ) ;
789
+ fs . appendFileSync ( deepFileA , Date . now ( ) ) ;
790
+ fs . appendFileSync ( deepFileB , Date . now ( ) ) ;
791
+ waitFor ( [ [ spy , 4 ] ] , function ( ) {
792
+ spy . should . have . been . calledWith ( 'change' , deepFileA ) ;
793
+ spy . should . have . been . calledWith ( 'change' , deepFileB ) ;
794
+ done ( ) ;
795
+ } ) ;
796
+ } ) ;
797
+ } ) ;
770
798
} ) ;
771
799
describe ( 'watch symlinks' , function ( ) {
772
800
if ( os === 'win32' ) return ;
@@ -1118,7 +1146,7 @@ function runTests(baseopts) {
1118
1146
describe ( 'ignored' , function ( ) {
1119
1147
it ( 'should check ignore after stating' , function ( done ) {
1120
1148
options . ignored = function ( path , stats ) {
1121
- if ( path === testDir || ! stats ) return false ;
1149
+ if ( upath . normalizeSafe ( path ) === upath . normalizeSafe ( testDir ) || ! stats ) return false ;
1122
1150
return stats . isDirectory ( ) ;
1123
1151
} ;
1124
1152
var spy = sinon . spy ( ) ;
0 commit comments