@@ -261,7 +261,8 @@ define(function (require, exports, module) {
261261 FileSystem . prototype . _watchOrUnwatchEntry = function ( entry , watchedRoot , callback , shouldWatch ) {
262262 var impl = this . _impl ,
263263 recursiveWatch = impl . recursiveWatch ,
264- commandName = shouldWatch ? "watchPath" : "unwatchPath" ;
264+ commandName = shouldWatch ? "watchPath" : "unwatchPath" ,
265+ filterGlobs = watchedRoot . filterGlobs ;
265266
266267 if ( recursiveWatch ) {
267268 // The impl can watch the entire subtree with one call on the root (we also fall into this case for
@@ -273,7 +274,7 @@ define(function (require, exports, module) {
273274 } else {
274275 // The impl will handle finding all subdirectories to watch.
275276 this . _enqueueWatchRequest ( function ( requestCb ) {
276- impl [ commandName ] . call ( impl , entry . fullPath , requestCb ) ;
277+ impl [ commandName ] . call ( impl , entry . fullPath , filterGlobs , requestCb ) ;
277278 } . bind ( this ) , callback ) ;
278279 }
279280 } else if ( shouldWatch ) {
@@ -314,7 +315,7 @@ define(function (require, exports, module) {
314315 } ;
315316
316317 entriesToWatch . forEach ( function ( entry ) {
317- impl . watchPath ( entry . fullPath , watchCallback ) ;
318+ impl . watchPath ( entry . fullPath , filterGlobs , watchCallback ) ;
318319 } ) ;
319320 } ) ;
320321 } , callback ) ;
@@ -851,11 +852,19 @@ define(function (require, exports, module) {
851852 * @param {function(string): boolean } filter - Returns true if a particular item should
852853 * be watched, given its name (not full path). Items that are ignored are also
853854 * filtered from Directory.getContents() results within this subtree.
855+ * @param {Array<string> } filterGlobs - glob compatible string definitions for
856+ * filtering out events on the node side.
854857 * @param {function(?string)= } callback - A function that is called when the watch has
855858 * completed. If the watch fails, the function will have a non-null FileSystemError
856859 * string parametr.
857860 */
858- FileSystem . prototype . watch = function ( entry , filter , callback ) {
861+ FileSystem . prototype . watch = function ( entry , filter , filterGlobs , callback ) {
862+ // make filterGlobs an optional argument to stay backwards compatible
863+ if ( typeof callback === "undefined" && typeof filterGlobs === "function" ) {
864+ callback = filterGlobs ;
865+ filterGlobs = null ;
866+ }
867+
859868 var fullPath = entry . fullPath ;
860869
861870 callback = callback || function ( ) { } ;
@@ -882,7 +891,7 @@ define(function (require, exports, module) {
882891 return ;
883892 }
884893
885- var watchedRoot = new WatchedRoot ( entry , filter ) ;
894+ var watchedRoot = new WatchedRoot ( entry , filter , filterGlobs ) ;
886895
887896 this . _watchedRoots [ fullPath ] = watchedRoot ;
888897
0 commit comments