Comparing version 0.2.1 to 0.2.2
module.exports = function(grunt) { | ||
'use strict'; | ||
grunt.loadNpmTasks('grunt-benchmark'); | ||
grunt.initConfig({ | ||
@@ -43,3 +42,6 @@ benchmark: { | ||
}); | ||
grunt.loadNpmTasks('grunt-benchmark'); | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-nodeunit'); | ||
grunt.registerTask('default', ['jshint', 'nodeunit']); | ||
}; |
@@ -150,4 +150,5 @@ /* | ||
// Close watchers | ||
Gaze.prototype.close = function() { | ||
Gaze.prototype.close = function(_reset) { | ||
var _this = this; | ||
_reset = _reset === false ? false : true; | ||
Object.keys(this._watchers).forEach(function(file) { | ||
@@ -161,4 +162,7 @@ _this._watchers[file].close(); | ||
}); | ||
this._watched = Object.create(null); | ||
_this.emit('end'); | ||
if (_reset) { | ||
this._watched = Object.create(null); | ||
this.removeAllListeners(); | ||
_this.emit('end'); | ||
} | ||
return this; | ||
@@ -184,3 +188,6 @@ }; | ||
}); | ||
}, done); | ||
}, function() { | ||
_this.close(false); | ||
_this._initWatched(done); | ||
}); | ||
}; | ||
@@ -250,5 +257,5 @@ | ||
Gaze.prototype._markDir = function(dir) { | ||
if (typeof dir === 'string' | ||
&& dir.slice(-(path.sep.length)) !== path.sep | ||
&& dir !== '.') { | ||
if (typeof dir === 'string' && | ||
dir.slice(-(path.sep.length)) !== path.sep && | ||
dir !== '.') { | ||
dir += path.sep; | ||
@@ -306,3 +313,3 @@ } | ||
else if (val) { obj[key].push(val); } | ||
return obj[key]; | ||
return obj[key] = _.unique(obj[key]); | ||
}; | ||
@@ -400,3 +407,3 @@ | ||
}); | ||
// Watch for change/rename events on files | ||
@@ -417,3 +424,3 @@ files.forEach(function(file) { | ||
}, function() { | ||
// Return this instance of Gaze | ||
@@ -420,0 +427,0 @@ // delay before ready solves a lot of issues |
{ | ||
"name": "gaze", | ||
"description": "A globbing fs.watch wrapper built from the best parts of other fine watch libs.", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"homepage": "https://github.com/shama/gaze", | ||
@@ -28,17 +28,20 @@ "author": { | ||
"scripts": { | ||
"test": "grunt nodeunit" | ||
"test": "grunt nodeunit -v" | ||
}, | ||
"dependencies": { | ||
"async": "~0.1.22", | ||
"glob": "~3.1.13", | ||
"lodash": "~0.8.0", | ||
"minimatch": "~0.2.6" | ||
"glob": "~3.1.14", | ||
"lodash": "~0.10.0", | ||
"minimatch": "~0.2.9" | ||
}, | ||
"devDependencies": { | ||
"grunt": "git://github.com/gruntjs/grunt.git#8b5b7c6af1fe7d4a2c62cee940d798664b53c7af", | ||
"grunt-benchmark": "~0.1.1" | ||
"grunt-benchmark": "~0.1.1", | ||
"grunt": "~0.4.0a", | ||
"grunt-contrib-nodeunit": "~0.1.1", | ||
"grunt-contrib-jshint": "~0.1.0" | ||
}, | ||
"keywords": [ | ||
"watch", "glob" | ||
"watch", | ||
"glob" | ||
] | ||
} | ||
} |
@@ -160,2 +160,3 @@ # gaze [![Build Status](https://secure.travis-ci.org/shama/gaze.png?branch=master)](http://travis-ci.org/shama/gaze) | ||
## Release History | ||
* 0.2.2 - Fix issue where subsequent add calls dont get watched (@samcday). removeAllListeners on close. | ||
* 0.2.1 - Fix issue with invalid `added` events in current working dir. | ||
@@ -172,3 +173,3 @@ * 0.2.0 - Support and mark folders with `path.sep`. Add `forceWatchMethod` option. Support `renamed` events. | ||
## License | ||
Copyright (c) 2012 Kyle Robinson Young | ||
Copyright (c) 2012 Kyle Robinson Young | ||
Licensed under the MIT license. |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
@@ -34,3 +35,18 @@ exports.add = { | ||
test.done(); | ||
}, | ||
addLater: function(test) { | ||
test.expect(3); | ||
new Gaze('sub/one.js', function(err, watcher) { | ||
test.deepEqual(watcher.relative('sub'), ['one.js']); | ||
watcher.add('sub/*.js', function() { | ||
test.deepEqual(watcher.relative('sub'), ['one.js', 'two.js']); | ||
watcher.on('changed', function(filepath) { | ||
test.equal('two.js', path.basename(filepath)); | ||
watcher.close(); | ||
test.done(); | ||
}); | ||
fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'two.js'), 'var two = true;'); | ||
}); | ||
}); | ||
} | ||
}; |
@@ -25,5 +25,5 @@ 'use strict'; | ||
gaze._addToWatched(files); | ||
test.deepEqual(gaze.relative('.'), ['Project (LO)/', 'nested/', 'one.js']); | ||
test.deepEqual(gaze.relative('.', true), ['Project (LO)/', 'nested/', 'one.js']); | ||
test.done(); | ||
} | ||
}; |
@@ -167,3 +167,3 @@ 'use strict'; | ||
}); | ||
fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'two.js'), 'var two = true;'); | ||
fs.writeFileSync(path.resolve(cwd, 'two.js'), 'var two = true;'); | ||
}); | ||
@@ -173,20 +173,25 @@ }, | ||
test.expect(3); | ||
var times = 0; | ||
var create = [ | ||
path.resolve(__dirname, 'fixtures', 'nested', 'sub', 'added.js'), | ||
path.resolve(__dirname, 'fixtures', 'added.js'), | ||
path.resolve(__dirname, 'fixtures', 'nested', 'added.js') | ||
]; | ||
var clean = []; | ||
function createFile() { | ||
var file = create.shift(); | ||
fs.writeFileSync(file, 'var added = true;'); | ||
clean.push(file); | ||
} | ||
gaze('**/*', {debounceDelay:100}, function(err, watcher) { | ||
watcher.on('added', function(filepath) { | ||
test.equal('added.js', path.basename(filepath)); | ||
fs.unlinkSync(filepath); | ||
times++; | ||
if (times > 2) { | ||
if (create.length < 1) { | ||
clean.forEach(fs.unlinkSync); | ||
watcher.close(); | ||
test.done(); | ||
} else { | ||
createFile(); | ||
} | ||
}); | ||
fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'nested', 'sub', 'added.js'), 'var added = true;'); | ||
setTimeout(function() { | ||
fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'added.js'), 'var added = true;'); | ||
}, 500); | ||
setTimeout(function() { | ||
fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'nested', 'added.js'), 'var added = true;'); | ||
}, 1000); | ||
createFile(); | ||
}); | ||
@@ -193,0 +198,0 @@ }, |
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
35742
23
877
174
4
4
+ Addedlodash@0.10.0(transitive)
- Removedlodash@0.8.2(transitive)
Updatedglob@~3.1.14
Updatedlodash@~0.10.0
Updatedminimatch@~0.2.9