Comparing version 1.0.4 to 1.1.0
{ | ||
"name": "sane", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "Sane aims to be fast, small, and reliable file system watcher.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -66,2 +66,42 @@ 'use strict'; | ||
this.watchProjectInfo = null; | ||
function getWatchRoot() { | ||
return self.watchProjectInfo ? self.watchProjectInfo.root : self.root; | ||
} | ||
function onVersion(error, resp) { | ||
if (handleError(self, error)) { | ||
return; | ||
} | ||
handleWarning(resp); | ||
var parts = resp.version.split('.'); | ||
if (parseInt(parts[0], 10) >= 3 && parseInt(parts[1], 10) >= 1) { | ||
self.client.command( | ||
['watch-project', getWatchRoot()], onWatchProject | ||
); | ||
} else { | ||
self.client.command(['watch', getWatchRoot()], onWatch); | ||
} | ||
} | ||
function onWatchProject(error, resp) { | ||
if (handleError(self, error)) { | ||
return; | ||
} | ||
handleWarning(resp); | ||
self.watchProjectInfo = { | ||
root: resp.watch, | ||
relativePath: resp.relative_path ? resp.relative_path : '' | ||
}; | ||
self.client.command(['clock', getWatchRoot()], onClock); | ||
} | ||
function onWatch(error, resp) { | ||
@@ -74,3 +114,3 @@ if (handleError(self, error)) { | ||
self.client.command(['clock', self.root], onClock); | ||
self.client.command(['clock', getWatchRoot()], onClock); | ||
} | ||
@@ -85,11 +125,22 @@ | ||
self.client.command(['subscribe', self.root, SUB_NAME, { | ||
var options = { | ||
fields: ['name', 'exists', 'new'], | ||
since: resp.clock | ||
}], onSubscribe); | ||
}; | ||
if (self.watchProjectInfo != null) { | ||
options.expression = [ | ||
'dirname', | ||
self.watchProjectInfo.relativePath | ||
]; | ||
} | ||
self.client.command( | ||
['subscribe', getWatchRoot(), SUB_NAME, options], | ||
onSubscribe | ||
); | ||
} | ||
function onSubscribe(error, resp) { | ||
if (error) { | ||
self.emit('error', error); | ||
if (handleError(self, error)) { | ||
return; | ||
@@ -103,3 +154,3 @@ } | ||
self.client.command(['watch', self.root], onWatch); | ||
self.client.command(['version'], onVersion); | ||
}; | ||
@@ -128,4 +179,13 @@ | ||
var self = this; | ||
var absPath = path.join(this.root, changeDescriptor.name); | ||
var absPath; | ||
if (this.watchProjectInfo && this.watchProjectInfo.relativePath.length) { | ||
absPath = path.join( | ||
this.watchProjectInfo.root, | ||
changeDescriptor.name | ||
); | ||
} else { | ||
absPath = path.join(this.root, changeDescriptor.name); | ||
} | ||
if (!common.isFileIncluded(this.globs, this.dot, changeDescriptor.name)) { | ||
@@ -132,0 +192,0 @@ return; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55562
1098