Comparing version 0.1.5 to 0.1.6
@@ -209,7 +209,8 @@ /* | ||
var relDir; | ||
var cwd = this.options.cwd || process.cwd(); | ||
Object.keys(this._watched).forEach(function(dir) { | ||
relDir = path.relative(process.cwd(), dir); | ||
relDir = path.relative(cwd, dir); | ||
if (relDir === '') { relDir = '.'; } | ||
relative[relDir] = _this._watched[dir].map(function(file) { | ||
return path.relative(path.join(process.cwd(), relDir), file); | ||
return path.relative(path.join(cwd, relDir), file); | ||
}); | ||
@@ -224,4 +225,5 @@ }); | ||
var dir; | ||
var cwd = _this.options.cwd || process.cwd(); | ||
files.forEach(function(file) { | ||
var filepath = path.resolve(process.cwd(), file); | ||
var filepath = path.resolve(cwd, file); | ||
// if mark false, use stat to figure the isDir | ||
@@ -300,2 +302,3 @@ if (_this.options.mark === false) { | ||
var _this = this; | ||
var cwd = this.options.cwd || process.cwd(); | ||
async.forEachSeries(Object.keys(_this._watched), function(dir, next) { | ||
@@ -306,3 +309,3 @@ var files = _this._watched[dir]; | ||
_this._watchFile(dir, function(event, dirpath) { | ||
var relDir = process.cwd() === dir ? '.' : path.relative(process.cwd(), dir); | ||
var relDir = cwd === dir ? '.' : path.relative(cwd, dir); | ||
return fs.readdir(dirpath, function(err, current) { | ||
@@ -309,0 +312,0 @@ if (err) { return _this.emit('error', err); } |
{ | ||
"name": "gaze", | ||
"description": "A globbing fs.watch wrapper built from the best parts of other fine watch libs.", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"homepage": "https://github.com/shama/gaze", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -141,2 +141,3 @@ # gaze [![Build Status](https://secure.travis-ci.org/shama/gaze.png?branch=master)](http://travis-ci.org/shama/gaze) | ||
## Release History | ||
* 0.1.6 - Recognize the `cwd` option properly | ||
* 0.1.5 - Catch too many open file errors | ||
@@ -143,0 +144,0 @@ * 0.1.4 - Really fix the race condition with 2 watches |
@@ -144,3 +144,24 @@ 'use strict'; | ||
}); | ||
}, | ||
nonExistent: function(test) { | ||
test.expect(1); | ||
gaze('non/existent/**/*', function(err, watcher) { | ||
test.ok(true); | ||
test.done(); | ||
}); | ||
}, | ||
differentCWD: function(test) { | ||
test.expect(1); | ||
var cwd = path.resolve(__dirname, 'fixtures', 'sub'); | ||
gaze('two.js', { | ||
cwd: cwd | ||
}, function(err, watcher) { | ||
watcher.on('changed', function(filepath) { | ||
test.deepEqual(this.relative(), {'.':['two.js']}); | ||
watcher.close(); | ||
test.done(); | ||
}); | ||
fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'two.js'), 'var two = true;'); | ||
}); | ||
} | ||
}; |
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
26850
649
152