66 */
77module . exports . plugin = function ( options , emitter ) {
88
9- // Options to pass along to Gaze
10- var watchOptions = options . get ( "watchOptions" ) || options . get ( "watchoptions" ) ;
9+ var defaultWatchOptions = require ( "immutable" ) . Map ( {
10+ ignored : / [ \/ \\ ] \. /
11+ } )
12+ . mergeDeep (
13+ options . get ( "watchOptions" ) || options . get ( "watchoptions" )
14+ )
15+ . toJS ( ) ;
1116
12- if ( watchOptions ) {
13- watchOptions = watchOptions . toJS ( ) ;
14- } else {
15- watchOptions = { } ;
16- }
17-
18- var globs = options . get ( "files" ) ;
19-
20- return globs . reduce ( function ( map , glob , namespace ) {
17+ return options . get ( "files" ) . reduce ( function ( map , glob , namespace ) {
2118
2219 /**
2320 * Default CB when not given
@@ -37,21 +34,21 @@ module.exports.plugin = function (options, emitter) {
3734 if ( jsItem . globs . length ) {
3835 if ( ! map [ namespace ] ) {
3936 map [ namespace ] = {
40- watchers : [ getWatcher ( jsItem . globs , watchOptions , fn ) ]
37+ watchers : [ getWatcher ( jsItem . globs , defaultWatchOptions , fn ) ]
4138 } ;
4239 } else {
43- map [ namespace ] . watchers . push ( getWatcher ( jsItem . globs , watchOptions , fn ) ) ;
40+ map [ namespace ] . watchers . push ( getWatcher ( jsItem . globs , defaultWatchOptions , fn ) ) ;
4441 }
4542 }
4643
4744 if ( jsItem . objs . length ) {
4845 jsItem . objs . forEach ( function ( item ) {
4946 if ( ! map [ namespace ] ) {
5047 map [ namespace ] = {
51- watchers : [ getWatcher ( item . match , watchOptions , item . fn ) ]
48+ watchers : [ getWatcher ( item . match , item . options || defaultWatchOptions , item . fn ) ]
5249 } ;
5350 } else {
54- map [ namespace ] . watchers . push ( getWatcher ( item . match , watchOptions , item . fn ) ) ;
51+ map [ namespace ] . watchers . push ( getWatcher ( item . match , item . options || defaultWatchOptions , item . fn ) ) ;
5552 }
5653 } ) ;
5754 }
@@ -62,10 +59,5 @@ module.exports.plugin = function (options, emitter) {
6259} ;
6360
6461function getWatcher ( patterns , opts , fn ) {
65-
66- if ( ! opts . ignored ) {
67- opts . ignored = / [ \/ \\ ] \. / ;
68- }
69-
7062 return require ( "chokidar" ) . watch ( patterns , opts ) . on ( "all" , fn ) ;
7163}
0 commit comments