Comparing version 0.4.0 to 0.5.0
@@ -0,1 +1,8 @@ | ||
# Chokidar 0.5.0 (December 9, 2012) | ||
* Added a bunch of new options: | ||
* `ignoreInitial` that allows to ignore initial `add` events. | ||
* `ignorePermissionErrors` that allows to ignore ENOENT etc perm errors. | ||
* `interval` and `binaryInterval` that allow to change default | ||
fs polling intervals. | ||
# Chokidar 0.4.0 (July 26, 2012) | ||
@@ -2,0 +9,0 @@ * Added `all` event that receives two args (event name and path) that |
@@ -1,6 +0,6 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
// Generated by CoffeeScript 1.4.0 | ||
(function() { | ||
'use strict'; | ||
var EventEmitter, FSWatcher, fs, nodeVersion, sysPath, | ||
var EventEmitter, FSWatcher, fs, isBinary, nodeVersion, sysPath, | ||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | ||
@@ -17,2 +17,4 @@ __hasProp = {}.hasOwnProperty, | ||
isBinary = require('./is-binary'); | ||
nodeVersion = process.versions.node.substring(0, 3); | ||
@@ -25,3 +27,3 @@ | ||
function FSWatcher(options) { | ||
var _base, _ref, | ||
var _base, _base1, _base2, _base3, _base4, _ref, _ref1, _ref2, _ref3, _ref4, | ||
_this = this; | ||
@@ -43,2 +45,4 @@ this.options = options != null ? options : {}; | ||
this._hasReadPermissions = __bind(this._hasReadPermissions, this); | ||
this._removeFromWatchedDir = __bind(this._removeFromWatchedDir, this); | ||
@@ -50,2 +54,3 @@ | ||
FSWatcher.__super__.constructor.apply(this, arguments); | ||
this.watched = Object.create(null); | ||
@@ -56,10 +61,23 @@ this.watchers = []; | ||
} | ||
this._ignored = (function() { | ||
switch (toString.call(_this.options.ignored)) { | ||
if ((_ref1 = (_base1 = this.options).ignoreInitial) == null) { | ||
_base1.ignoreInitial = false; | ||
} | ||
if ((_ref2 = (_base2 = this.options).ignorePermissionErrors) == null) { | ||
_base2.ignorePermissionErrors = false; | ||
} | ||
if ((_ref3 = (_base3 = this.options).interval) == null) { | ||
_base3.interval = 100; | ||
} | ||
if ((_ref4 = (_base4 = this.options).binaryInterval) == null) { | ||
_base4.binaryInterval = 100; | ||
} | ||
this.enableBinaryInterval = this.options.binaryInterval !== this.options.interval; | ||
this._ignored = (function(ignored) { | ||
switch (toString.call(ignored)) { | ||
case '[object RegExp]': | ||
return function(string) { | ||
return this.options.ignored.test(string); | ||
return ignored.test(string); | ||
}; | ||
case '[object Function]': | ||
return _this.options.ignored; | ||
return ignored; | ||
default: | ||
@@ -70,3 +88,4 @@ return function() { | ||
} | ||
})(); | ||
})(this.options.ignored); | ||
Object.freeze(this.options); | ||
} | ||
@@ -98,2 +117,6 @@ | ||
FSWatcher.prototype._hasReadPermissions = function(stats) { | ||
return Boolean(4 & parseInt((stats.mode & 0x1ff).toString(8)[0])); | ||
}; | ||
FSWatcher.prototype._remove = function(directory, item) { | ||
@@ -132,6 +155,6 @@ var fullPath, nestedDirectoryChildren, | ||
}); | ||
this.watchers.push(watcher); | ||
return this.watchers.push(watcher); | ||
} else { | ||
options.interval = 100; | ||
fs.watchFile(item, options, function(curr, prev) { | ||
options.interval = this.enableBinaryInterval && isBinary(basename) ? this.options.binaryInterval : this.options.interval; | ||
return fs.watchFile(item, options, function(curr, prev) { | ||
if (curr.mtime.getTime() !== prev.mtime.getTime()) { | ||
@@ -142,12 +165,15 @@ return callback(item); | ||
} | ||
if (itemType === 'file') { | ||
return this.emit('add', item); | ||
} | ||
}; | ||
FSWatcher.prototype._handleFile = function(file) { | ||
FSWatcher.prototype._handleFile = function(file, initialAdd) { | ||
var _this = this; | ||
return this._watch(file, 'file', function(file) { | ||
if (initialAdd == null) { | ||
initialAdd = false; | ||
} | ||
this._watch(file, 'file', function(file) { | ||
return _this.emit('change', file); | ||
}); | ||
if (!(initialAdd && this.options.ignoreInitial)) { | ||
return this.emit('add', file); | ||
} | ||
}; | ||
@@ -176,3 +202,3 @@ | ||
}).forEach(function(file) { | ||
return _this._handle(sysPath.join(directory, file)); | ||
return _this._handle(sysPath.join(directory, file), previous.length === 0); | ||
}); | ||
@@ -185,4 +211,7 @@ }); | ||
FSWatcher.prototype._handle = function(item) { | ||
FSWatcher.prototype._handle = function(item, initialAdd) { | ||
var _this = this; | ||
if (initialAdd == null) { | ||
initialAdd = false; | ||
} | ||
if (this._ignored(item)) { | ||
@@ -199,4 +228,7 @@ return; | ||
} | ||
if (_this.options.ignorePermissionErrors && (!_this._hasReadPermissions(stats))) { | ||
return; | ||
} | ||
if (stats.isFile()) { | ||
_this._handleFile(item); | ||
_this._handleFile(item, initialAdd); | ||
} | ||
@@ -203,0 +235,0 @@ if (stats.isDirectory()) { |
{ | ||
"name": "chokidar", | ||
"description": "A neat wrapper around node.js fs.watch / fs.watchFile.", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"keywords": ["fs", "watch", "watchFile", "watcher", "file"], | ||
@@ -30,5 +30,8 @@ "homepage": "https://github.com/paulmillr/chokidar", | ||
"devDependencies": { | ||
"mocha": "1.3.0", | ||
"expect.js": "0.1.2" | ||
"mocha": "~1.7.3", | ||
"chai": "~1.4.0", | ||
"sinon": "~1.5.2", | ||
"sinon-chai": "2.2.0", | ||
"coffee-script": "~1.4.0" | ||
} | ||
} |
@@ -15,3 +15,2 @@ # Chokidar | ||
* Doesn't work on windows | ||
* Almost as shitty in event tracking. | ||
@@ -21,3 +20,7 @@ | ||
It is used in [brunch](http://brunch.io) and had proven itself in production env. | ||
It is used in | ||
[brunch](http://brunch.io), | ||
[socketstream](http://www.socketstream.org), | ||
and [testacular](https://github.com/vojtajina/testacular/) | ||
and had proven itself in production env. | ||
@@ -53,4 +56,10 @@ ## Getting started | ||
`chokidar.watch('file', {ignored: /^\./})`. | ||
* `options.persistent` (default: `false`). indicates whether the process | ||
* `options.persistent` (default: `false`). Indicates whether the process | ||
should continue to run as long as files are being watched. | ||
* `options.ignorePermissionErrors` (default: `false`). Indicates | ||
whether to watch files that don't have read permissions or not. | ||
* `options.ignoreInitial` (default: `false`). Indicates whether chokidar | ||
should ignore initial `add` events or not. | ||
* `options.interval` (default: `100`). Interval of file system polling. | ||
* `options.binaryInterval` (default: `100`). Interval of file system polling for binary files. | ||
@@ -62,3 +71,4 @@ `chokidar.watch()` produces an instance of `FSWatcher`. Methods of `FSWatcher`: | ||
* `.on(event, callback)`: listen for an FS event. | ||
Available events: `add`, `change`, `unlink`, `error`, `all`. | ||
Available events: `add`, `change`, `unlink`, `error`. | ||
Also, `all` is available which emitted for every `add`, `change` and `unlink`. | ||
* `.close()`: remove all listeners from watched files. | ||
@@ -65,0 +75,0 @@ |
@@ -29,3 +29,3 @@ var exec = require('child_process').exec; | ||
execute(['node_modules', 'mocha', 'bin', 'mocha'], | ||
'--compilers coffee:coffee-script --require test/common.coffee --colors'); | ||
'--compilers coffee:coffee-script --require test/common.js --colors'); | ||
} |
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
28782
14
288
94
1
5