Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Make file watching compatible with node version 6.x (runs on 0.10 too) #12647

Merged
merged 37 commits into from
Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cc1d350
Use chokidar instead of the fsevents/fsevents_win combo
Feb 3, 2016
c0aa471
Add 'depth' parameter
Feb 4, 2016
61888e6
Add some logs
ficristo Feb 7, 2016
2e3210b
Use the stats from chokidar
ficristo Apr 18, 2016
adfd64d
Prepared preferences for the paths to ignore during watching
ficristo May 14, 2016
68f6c37
Make tests pass
Aug 3, 2016
a34d926
do not commit node_modules to the project
zaggino Aug 3, 2016
63f58f8
do not ignore stuff by default in the domain
zaggino Aug 4, 2016
7733f4a
propagate ignores from FileSystem.js
zaggino Aug 4, 2016
2dc6a70
stats are not always available (deletes)
zaggino Aug 4, 2016
c9758b4
chokidar allows recursive watching in linux
zaggino Aug 4, 2016
7163ff7
watchedRoot.filter should be used to ignore files from watching
zaggino Aug 4, 2016
b59f7b8
fix project switching blocker
zaggino Aug 5, 2016
0d5c9dc
do not hide true event names from shell file system
zaggino Aug 5, 2016
49c82fb
correctly transfer stats from watcher domain
zaggino Aug 5, 2016
e8117a0
make stuff slightly faster using test instead of match
zaggino Aug 16, 2016
412e5ed
add node side filter to the watched root class
zaggino Aug 16, 2016
26301f5
pass exclusionGlob to WatchedRoot
zaggino Aug 16, 2016
3fe4876
implemented and tested ignoring
zaggino Aug 16, 2016
65bc4f8
exclude node_modules too
zaggino Aug 18, 2016
c9b9dbb
added npm-shrinkwrap
zaggino Aug 23, 2016
b54781a
more readable condition
zaggino Aug 23, 2016
9a6d16e
use simplified group of watch events
zaggino Aug 23, 2016
be4c7c8
explain better
zaggino Aug 23, 2016
b431042
add c# file watcher executables from vscode
zaggino Aug 23, 2016
c4a226f
add useful options to chokidar
zaggino Aug 23, 2016
2b2bfc1
add glob
zaggino Aug 23, 2016
48c200e
refactoring
zaggino Aug 23, 2016
8b7c0b1
implement CSharpWatcher
zaggino Aug 23, 2016
23f687e
avoid circular dependency errors
zaggino Aug 23, 2016
68fe2f1
do not notify about terminations when closing watcher
zaggino Aug 23, 2016
1096f74
optimize: do not call domain function with an empty list
zaggino Aug 23, 2016
3cf15ea
ensure _hash is present in file system stats
zaggino Aug 23, 2016
9c78e36
fix the bug with shell rounding the stats mtime causing false blind w…
zaggino Aug 23, 2016
84b5fa7
add MS license for CodeHelper.exe
zaggino Aug 23, 2016
9077970
add adobe license headers to new files
zaggino Aug 24, 2016
4e17c98
add npm install --production script to grunt build
zaggino Aug 24, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ module.exports = function (grunt) {
/*'cssmin',*/
/*'uglify',*/
'copy',
'npm-install',
'cleanempty',
'usemin',
'build-config'
Expand Down
281 changes: 281 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"branch": "",
"SHA": ""
},
"dependencies": {
"anymatch": "1.3.0",
"chokidar": "1.6.0"
},
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to this PR

"devDependencies": {
"grunt": "0.4.5",
"jasmine-node": "1.11.0",
Expand Down
4 changes: 4 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"branch": "",
"SHA": ""
},
"dependencies": {
"anymatch": "1.3.0",
"chokidar": "1.6.0"
},
"devDependencies": {
"grunt": "0.4.5",
"jasmine-node": "1.11.0",
Expand Down
19 changes: 14 additions & 5 deletions src/filesystem/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this logic for backward compatibility? If so add a comment.
(I always find this kind of things hard to follow...)
Is the second condition necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 () {};
Expand All @@ -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;

Expand Down
8 changes: 6 additions & 2 deletions src/filesystem/FileSystemStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Collaborator

@ficristo ficristo Aug 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment when mtime is not a instanceof Date?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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) {
Expand Down
Loading