Comparing version 0.2.3 to 0.2.4
@@ -0,1 +1,4 @@ | ||
# Chokidar 0.2.4 (June 7, 2012) | ||
* Fixed a bug when unlinked files emitted events after unlink. | ||
# Chokidar 0.2.3 (May 12, 2012) | ||
@@ -2,0 +5,0 @@ * Fixed watching of files on windows. |
@@ -9,7 +9,7 @@ 'use strict'; | ||
// Watches files & directories for changes. | ||
// | ||
// | ||
// Emitted events: `add`, `change`, `unlink`, `error`. | ||
// | ||
// | ||
// Examples | ||
// | ||
// | ||
// var watcher = new FSWatcher() | ||
@@ -53,7 +53,22 @@ // .add(directories) | ||
FSWatcher.prototype._addToWatchedDir = function(directory, file) { | ||
var watchedFiles = this._getWatchedDir(directory); | ||
watchedFiles.push(file); | ||
}; | ||
FSWatcher.prototype._removeFromWatchedDir = function(directory, file) { | ||
var watchedFiles = this._getWatchedDir(directory); | ||
watchedFiles.some(function(watchedFile, index) { | ||
if (watchedFile === file) { | ||
watchedFiles.splice(index, 1); | ||
return true; | ||
} | ||
}); | ||
}; | ||
// Private: Watch file for changes with fs.watchFile or fs.watch. | ||
// | ||
// | ||
// item - string, path to file or directory. | ||
// callback - function that will be executed on fs change. | ||
// | ||
// | ||
// Returns nothing. | ||
@@ -91,5 +106,5 @@ FSWatcher.prototype._watch = function(item, callback) { | ||
// once the file is changed. | ||
// | ||
// | ||
// file - string, fs path. | ||
// | ||
// | ||
// Returns nothing. | ||
@@ -106,5 +121,5 @@ FSWatcher.prototype._handleFile = function(file) { | ||
// and re-read it on change. | ||
// | ||
// | ||
// directory - string, fs path. | ||
// | ||
// | ||
// Returns nothing. | ||
@@ -127,6 +142,5 @@ FSWatcher.prototype._handleDir = function(directory) { | ||
}) | ||
.forEach(function(file, index) { | ||
var path = sysPath.join(directory, file); | ||
previous.splice(index, 1); | ||
_this.emit('unlink', path); | ||
.forEach(function(file) { | ||
_this._removeFromWatchedDir(directory, file); | ||
_this.emit('unlink', sysPath.join(directory, file)); | ||
}); | ||
@@ -142,2 +156,3 @@ | ||
.forEach(function(file) { | ||
_this._addToWatchedDir(directory, file); | ||
_this._handle(sysPath.join(directory, file)); | ||
@@ -153,5 +168,5 @@ }); | ||
// Delegates call to _handleFile / _handleDir after checks. | ||
// | ||
// | ||
// item - string, path to file or directory. | ||
// | ||
// | ||
// Returns nothing. | ||
@@ -175,9 +190,9 @@ FSWatcher.prototype._handle = function(item) { | ||
// Public: Adds directories / files for tracking. | ||
// | ||
// | ||
// * files - array of strings (file paths). | ||
// | ||
// | ||
// Examples | ||
// | ||
// | ||
// add ['app', 'vendor'] | ||
// | ||
// | ||
// Returns an instance of FSWatcher for chaning. | ||
@@ -184,0 +199,0 @@ FSWatcher.prototype.add = function(files) { |
{ | ||
"name": "chokidar", | ||
"description": "A neat wrapper around node.js fs.watch / fs.watchFile.", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"keywords": ["fs", "watch", "watchFile", "watcher", "file"], | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/paulmillr/chokidar", |
@@ -65,3 +65,3 @@ # Chokidar | ||
Copyright (c) Paul Miller (http://paulmillr.com) | ||
Copyright (c) 2012 Paul Miller (http://paulmillr.com) | ||
@@ -68,0 +68,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of |
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
10969
199
1