Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chokidar

Package Overview
Dependencies
Maintainers
1
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chokidar - npm Package Compare versions

Comparing version 0.8.1 to 0.8.2

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# Chokidar 0.8.2 (26 March 2014)
* Fixed npm issues related to fsevents dep.
* Updated fsevents to 0.2.
# Chokidar 0.8.1 (16 December 2013)

@@ -2,0 +6,0 @@ * Optional deps are now truly optional on windows and

122

index.js

@@ -112,4 +112,4 @@ 'use strict';

FSWatcher.prototype._getWatchedDir = function(directory) {
var dir, _base;
dir = directory.replace(directoryEndRe, '');
var _base;
var dir = directory.replace(directoryEndRe, '');
return (_base = this.watched)[dir] != null ? (_base = this.watched)[dir] : _base[dir] = [];

@@ -119,4 +119,3 @@ };

FSWatcher.prototype._addToWatchedDir = function(directory, basename) {
var watchedFiles;
watchedFiles = this._getWatchedDir(directory);
var watchedFiles = this._getWatchedDir(directory);
return watchedFiles.push(basename);

@@ -126,4 +125,3 @@ };

FSWatcher.prototype._removeFromWatchedDir = function(directory, file) {
var watchedFiles;
watchedFiles = this._getWatchedDir(directory);
var watchedFiles = this._getWatchedDir(directory);
return watchedFiles.some(function(watchedFile, index) {

@@ -189,5 +187,4 @@ if (watchedFile === file) {

FSWatcher.prototype._watchWithFsEvents = function(path) {
var watcher,
_this = this;
watcher = createFSEventsInstance(path, function(path, flags) {
var _this = this;
var watcher = createFSEventsInstance(path, function(path, flags) {
var emit, info;

@@ -239,14 +236,12 @@ if (_this._isIgnored(path)) {

parent = this._getWatchedDir(directory);
if (parent.indexOf(basename) !== -1) {
return;
}
if (parent.indexOf(basename) !== -1) return;
this._addToWatchedDir(directory, basename);
options = {
persistent: this.options.persistent
};
options = {persistent: this.options.persistent};
if (this.options.usePolling) {
options.interval = this.enableBinaryInterval && isBinaryPath(basename) ? this.options.binaryInterval : this.options.interval;
return fs.watchFile(item, options, function(curr, prev) {
fs.watchFile(item, options, function(curr, prev) {
if (curr.mtime.getTime() > prev.mtime.getTime()) {
return callback(item, curr);
callback(item, curr);
}

@@ -256,5 +251,5 @@ });

watcher = fs.watch(item, options, function(event, path) {
return callback(item);
callback(item);
});
return this.watchers.push(watcher);
this.watchers.push(watcher);
}

@@ -273,5 +268,3 @@ };

var _this = this;
if (initialAdd == null) {
initialAdd = false;
}
if (initialAdd == null) initialAdd = false;
this._watch(file, function(file, newStats) {

@@ -292,15 +285,9 @@ return _this.emit('change', file, newStats);

FSWatcher.prototype._handleDir = function(directory, stats, initialAdd) {
var read,
_this = this;
read = function(directory, initialAdd) {
var _this = this;
var read = function(directory, initialAdd) {
return fs.readdir(directory, function(error, current) {
var previous;
if (error != null) {
return _this.emit('error', error);
}
if (!current) {
return;
}
if (error != null) return _this.emit('error', error);
if (!current) return;
previous = _this._getWatchedDir(directory);
var previous = _this._getWatchedDir(directory);

@@ -343,16 +330,8 @@ // Files that absent in current directory snapshot

var _this = this;
if (this._isIgnored(item)) {
return;
}
if (this._isIgnored(item)) return;
return fs.realpath(item, function(error, path) {
if (error && error.code === 'ENOENT') {
return;
}
if (error != null) {
return _this.emit('error', error);
}
return fs.stat(path, function(error, stats) {
if (error != null) {
return _this.emit('error', error);
}
if (error && error.code === 'ENOENT') return;
if (error != null) return _this.emit('error', error);
fs.stat(path, function(error, stats) {
if (error != null) return _this.emit('error', error);
if (_this.options.ignorePermissionErrors && (!_this._hasReadPermissions(stats))) {

@@ -364,8 +343,4 @@ return;

}
if (stats.isFile()) {
_this._handleFile(item, stats, initialAdd);
}
if (stats.isDirectory()) {
return _this._handleDir(item, stats, initialAdd);
}
if (stats.isFile()) _this._handleFile(item, stats, initialAdd);
if (stats.isDirectory()) _this._handleDir(item, stats, initialAdd);
});

@@ -385,5 +360,4 @@ });

FSWatcher.prototype._addToFsEvents = function(files) {
var handle,
_this = this;
handle = function(path) {
var _this = this;
var handle = function(path) {
return _this.emit('add', path);

@@ -394,11 +368,8 @@ };

fs.stat(file, function(error, stats) {
if (error != null) {
return _this.emit('error', error);
}
if (error != null) return _this.emit('error', error);
if (stats.isDirectory()) {
return recursiveReaddir(file, function(error, dirFiles) {
if (error != null) {
return _this.emit('error', error);
}
return dirFiles.filter(function(path) {
recursiveReaddir(file, function(error, dirFiles) {
if (error != null) return _this.emit('error', error);
dirFiles.filter(function(path) {
return !_this._isIgnored(path);

@@ -408,7 +379,7 @@ }).forEach(handle);

} else {
return handle(file);
handle(file);
}
});
}
return _this._watchWithFsEvents(file);
_this._watchWithFsEvents(file);
});

@@ -428,3 +399,2 @@ return this;

FSWatcher.prototype.add = function(files) {
var _this = this;
if (this._initialAdd == null) this._initialAdd = true;

@@ -436,4 +406,4 @@ if (!Array.isArray(files)) files = [files];

files.forEach(function(file) {
return _this._handle(file, _this._initialAdd);
});
return this._handle(file, this._initialAdd);
}, this);
this._initialAdd = false;

@@ -446,13 +416,12 @@ return this;

FSWatcher.prototype.close = function() {
var _this = this;
var useFsEvents = this.options.useFsEvents;
var method = useFsEvents ? 'stop' : 'close';
this.watchers.forEach(function(watcher) {
if (_this.options.useFsEvents) {
return watcher.stop();
} else {
return watcher.close();
}
watcher[method]();
});
if (this.options.usePolling) {
Object.keys(this.watched).forEach(function(directory) {
return _this.watched[directory].forEach(function(file) {
var watched = this.watched;
Object.keys(watched).forEach(function(directory) {
return watched[directory].forEach(function(file) {
return fs.unwatchFile(sysPath.join(directory, file));

@@ -463,2 +432,3 @@ });

this.watched = Object.create(null);
this.removeAllListeners();

@@ -465,0 +435,0 @@ return this;

{
"name": "chokidar",
"description": "A neat wrapper around node.js fs.watch / fs.watchFile.",
"version": "0.8.1",
"version": "0.8.2",
"keywords": [

@@ -28,4 +28,3 @@ "fs",

"scripts": {
"test": "./node_modules/.bin/mocha",
"postinstall": "node setup-deps.js"
"test": "./node_modules/.bin/mocha"
},

@@ -39,3 +38,7 @@ "devDependencies": {

"rimraf": "~2.2.2"
},
"optionalDependencies": {
"fsevents": "0.2.0",
"recursive-readdir": "0.0.2"
}
}

@@ -10,3 +10,3 @@ # Chokidar

* Doesn't report filenames on mac.
* Doesn't report events at all when using editors like TextMate2 on mac.
* Doesn't report events at all when using editors like Sublime on mac.
* Sometimes reports events twice.

@@ -20,2 +20,6 @@ * Has only one non-useful event: `rename`.

Other node.js watching libraries:
* Are not using ultra-fast non-polling watcher implementation on OS X
Chokidar resolves these problems.

@@ -22,0 +26,0 @@

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