Socket
Socket
Sign inDemoInstall

gaze

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gaze - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

2

Gruntfile.js

@@ -11,3 +11,3 @@ module.exports = function(grunt) {

nodeunit: {
files: ['test/**/*_test.js'],
files: ['test/*_test.js'],
},

@@ -14,0 +14,0 @@ jshint: {

@@ -123,2 +123,15 @@ /*

// Detect if new folder added to trigger for matching files within folder
if (e === 'added') {
if (helper.isDir(filepath)) {
fs.readdirSync(filepath).map(function(file) {
return path.join(filepath, file);
}).filter(function(file) {
return globule.isMatch(self._patterns, file, self.options);
}).forEach(function(file) {
self.emit('added', file);
});
}
}
return this;

@@ -186,5 +199,5 @@ };

var index = self._watched[dir].indexOf(file);
if (index) {
if (index !== -1) {
self._unpollFile(file);
delete self._watched[dir][index];
self._watched[dir].splice(index, 1);
return false;

@@ -244,2 +257,7 @@ }

// If a new dir is added
if (helper.isDir(file) && !(filepath in this._watched)) {
helper.objectPush(this._watched, filepath, []);
}
if (file.slice(-1) === '/') { filepath += path.sep; }

@@ -390,3 +408,3 @@ helper.objectPush(this._watched, path.dirname(filepath) + path.sep, filepath);

self.emit('ready', self);
done.call(self, null, self);
if (done) { done.call(self, null, self); }
}, delay + 100);

@@ -393,0 +411,0 @@

{
"name": "gaze",
"description": "A globbing fs.watch wrapper built from the best parts of other fine watch libs.",
"version": "0.4.1",
"version": "0.4.2",
"homepage": "https://github.com/shama/gaze",

@@ -6,0 +6,0 @@ "author": {

# gaze [![Build Status](https://secure.travis-ci.org/shama/gaze.png?branch=master)](http://travis-ci.org/shama/gaze)
A globbing fs.watch wrapper built from the best parts of other fine watch libs.
A globbing fs.watch wrapper built from the best parts of other fine watch libs.
Compatible with Node.js 0.10/0.8, Windows, OSX and Linux.
![gaze](http://dontkry.com/images/repos/gaze.png)
## Usage

@@ -154,2 +155,3 @@ Install the module with: `npm install gaze` or place into your `package.json`

## Release History
* 0.4.2 - Fix .remove() method to remove a single file in a directory (@kaelzhang). Fixing Cannot call method 'call' of undefined (@krasimir). Track new file additions within folders (@brett-shwom).
* 0.4.1 - Fix watchDir not respecting close in race condition (@chrisirhc).

@@ -174,3 +176,3 @@ * 0.4.0 - Drop support for node v0.6. Use globule for file matching. Avoid node v0.10 path.resolve/join errors. Register new files when added to non-existent folder. Multiple instances can now poll the same files (@jpommerening).

## License
Copyright (c) 2013 Kyle Robinson Young
Copyright (c) 2013 Kyle Robinson Young
Licensed under the MIT license.

@@ -54,3 +54,17 @@ 'use strict';

});
}
},
addNoCallback: function(test) {
test.expect(1);
new Gaze('sub/one.js', function(err, watcher) {
this.add('sub/two.js');
this.on('changed', function(filepath) {
test.equal('two.js', path.basename(filepath));
watcher.close();
test.done();
});
setTimeout(function() {
fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'two.js'), 'var two = true;');
}, 500);
});
},
};

@@ -89,5 +89,8 @@ 'use strict';

}, 1000);
watcher.on('end', test.done);
watcher.on('end', function() {
// TODO: Figure out why this test is finicky leaking it's newfolder into the other tests
setTimeout(test.done, 2000);
});
});
},
};

@@ -17,3 +17,3 @@ 'use strict';

'nested/.tmp',
'nested/sub/added.js'
'nested/sub/added.js',
].forEach(function(d) {

@@ -23,2 +23,5 @@ var p = path.resolve(__dirname, 'fixtures', d);

});
grunt.file.delete(path.resolve(__dirname, 'fixtures', 'new_dir'));
done();

@@ -246,2 +249,34 @@ }

},
mkdirThenAddFile: function(test) {
test.expect(3);
var expected = [
'new_dir',
'new_dir/tmp.js',
'new_dir/other.js',
];
gaze('**/*.js', function(err, watcher) {
watcher.on('all', function(status, filepath) {
var expect = expected.shift();
test.equal(path.relative(process.cwd(), filepath), expect);
if (expected.length === 1) {
// Ensure the new folder is being watched correctly after initial add
setTimeout(function() {
fs.writeFileSync('new_dir/dontmatch.txt', '');
setTimeout(function() {
fs.writeFileSync('new_dir/other.js', '');
}, 1000);
}, 1000);
}
if (expected.length < 1) { watcher.close(); }
});
grunt.file.write('new_dir/tmp.js', '');
watcher.on('end', test.done);
});
},
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc