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.1.3 to 0.1.4

15

lib/gaze.js

@@ -267,9 +267,18 @@ /*

var opts = Object.create(this.options);
var once = _.once(done);
// TODO: Optimize this. Should kill the other func per event
// then unwatch files to not even bother using the method
var watchOne = function() { done(null, file); };
var watchTwo = function() { done(null, file); };
_this._watchers[file] = fs.watch(file, opts, function(event) {
once(event, file);
if (typeof watchOne === 'function') {
watchTwo = null;
watchOne();
}
});
fs.watchFile(file, opts, function(curr, prev) {
if (curr.mtime.getTime() !== prev.mtime.getTime()) {
once(null, file);
if (typeof watchTwo === 'function') {
watchOne = null;
watchTwo();
}
}

@@ -276,0 +285,0 @@ });

2

package.json
{
"name": "gaze",
"description": "A globbing fs.watch wrapper built from the best parts of other fine watch libs.",
"version": "0.1.3",
"version": "0.1.4",
"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.4 - Really fix the race condition with 2 watches
* 0.1.3 - Fix race condition with 2 watches

@@ -143,0 +144,0 @@ * 0.1.2 - Read triggering changed event fix

@@ -125,3 +125,22 @@ 'use strict';

});
},
emitTwice: function(test) {
test.expect(2);
var times = 0;
gaze('**/*', function(err, watcher) {
watcher.on('all', function(status, filepath) {
test.equal(status, 'changed');
times++;
setTimeout(function() {
if (times < 2) {
fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'one.js'), 'var one = true;');
} else {
watcher.close();
test.done();
}
}, 1000);
});
fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'one.js'), 'var one = true;');
});
}
};
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