-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Make file watching compatible with node version 6.x (runs on 0.10 too) #12647
Changes from all commits
cc1d350
c0aa471
61888e6
2e3210b
adfd64d
68f6c37
a34d926
63f58f8
7733f4a
2dc6a70
c9758b4
7163ff7
b59f7b8
0d5c9dc
49c82fb
e8117a0
412e5ed
26301f5
3fe4876
65bc4f8
c9b9dbb
b54781a
9a6d16e
be4c7c8
b431042
c4a226f
2b2bfc1
48c200e
8b7c0b1
23f687e
68fe2f1
1096f74
3cf15ea
9c78e36
84b5fa7
9077970
4e17c98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,7 +261,8 @@ define(function (require, exports, module) { | |
FileSystem.prototype._watchOrUnwatchEntry = function (entry, watchedRoot, callback, shouldWatch) { | ||
var impl = this._impl, | ||
recursiveWatch = impl.recursiveWatch, | ||
commandName = shouldWatch ? "watchPath" : "unwatchPath"; | ||
commandName = shouldWatch ? "watchPath" : "unwatchPath", | ||
filterGlobs = watchedRoot.filterGlobs; | ||
|
||
if (recursiveWatch) { | ||
// 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) { | |
} else { | ||
// The impl will handle finding all subdirectories to watch. | ||
this._enqueueWatchRequest(function (requestCb) { | ||
impl[commandName].call(impl, entry.fullPath, requestCb); | ||
impl[commandName].call(impl, entry.fullPath, filterGlobs, requestCb); | ||
}.bind(this), callback); | ||
} | ||
} else if (shouldWatch) { | ||
|
@@ -314,7 +315,7 @@ define(function (require, exports, module) { | |
}; | ||
|
||
entriesToWatch.forEach(function (entry) { | ||
impl.watchPath(entry.fullPath, watchCallback); | ||
impl.watchPath(entry.fullPath, filterGlobs, watchCallback); | ||
}); | ||
}); | ||
}, callback); | ||
|
@@ -851,11 +852,19 @@ define(function (require, exports, module) { | |
* @param {function(string): boolean} filter - Returns true if a particular item should | ||
* be watched, given its name (not full path). Items that are ignored are also | ||
* filtered from Directory.getContents() results within this subtree. | ||
* @param {Array<string>} filterGlobs - glob compatible string definitions for | ||
* filtering out events on the node side. | ||
* @param {function(?string)=} callback - A function that is called when the watch has | ||
* completed. If the watch fails, the function will have a non-null FileSystemError | ||
* string parametr. | ||
*/ | ||
FileSystem.prototype.watch = function (entry, filter, callback) { | ||
FileSystem.prototype.watch = function (entry, filter, filterGlobs, callback) { | ||
// make filterGlobs an optional argument to stay backwards compatible | ||
if (typeof callback === "undefined" && typeof filterGlobs === "function") { | ||
callback = filterGlobs; | ||
filterGlobs = null; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this logic for backward compatibility? If so add a comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated the condition so it's hopefully more readable, added a comment |
||
|
||
var fullPath = entry.fullPath; | ||
|
||
callback = callback || function () {}; | ||
|
@@ -882,7 +891,7 @@ define(function (require, exports, module) { | |
return; | ||
} | ||
|
||
var watchedRoot = new WatchedRoot(entry, filter); | ||
var watchedRoot = new WatchedRoot(entry, filter, filterGlobs); | ||
|
||
this._watchedRoots[fullPath] = watchedRoot; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,9 +36,13 @@ define(function (require, exports, module) { | |
|
||
this._isFile = isFile; | ||
this._isDirectory = !isFile; | ||
this._mtime = options.mtime; | ||
// in case of stats transferred over a node-domain, | ||
// mtime will have JSON-ified value which needs to be restored | ||
this._mtime = options.mtime instanceof Date ? options.mtime : new Date(options.mtime); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a comment when mtime is not a instanceof Date? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added comment |
||
this._size = options.size; | ||
this._hash = options.hash; | ||
// hash is a property introduced by brackets and it's calculated | ||
// as a valueOf modification time -> calculate here if it's not present | ||
this._hash = options.hash || this._mtime.valueOf(); | ||
|
||
var realPath = options.realPath; | ||
if (realPath) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should start using a npm srinkwrap file asap if we start to use the dependecies fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to this PR