Socket
Socket
Sign inDemoInstall

chokidar

Package Overview
Dependencies
Maintainers
2
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.12.0 to 0.12.1

101

lib/fsevents-handler.js

@@ -34,3 +34,4 @@ 'use strict';

return Object.keys(FSEventsWatchers).some(function(watchedPath) {
if (!watchPath.indexOf(watchedPath)) {
// condition is met when indexOf returns 0
if (!sysPath.resolve(watchPath).indexOf(sysPath.resolve(watchedPath))) {
watchPath = watchedPath;

@@ -102,31 +103,30 @@ return true;

if (event === 'unlink') {
// suppress unlink events on never before seen files (from atomic write)
// suppress unlink events on never before seen files
if (info.type === 'directory' || watchedDir.has(item)) {
this._remove(parent, item);
} else {
fs.stat(path, function(error, stats) {
if (!stats || checkIgnored(stats)) return;
info.type = stats.isDirectory() ? 'directory' : 'file';
handleEvent('add');
});
}
return; // Don't emit event twice.
}
if (checkIgnored()) return;
if (event === 'add') {
this._getWatchedDir(parent).add(item);
if (info.type === 'directory') {
this._getWatchedDir(path);
} else if (info.type === 'symlink' && this.options.followSymlinks) {
return this._addToFsEvents(path, false, true);
} else if (!checkIgnored()) {
if (event === 'add') {
this._getWatchedDir(parent).add(item);
if (info.type === 'directory') {
this._getWatchedDir(path);
} else if (info.type === 'symlink' && this.options.followSymlinks) {
return this._addToFsEvents(path, false, true);
}
}
var eventName = info.type === 'directory' ? event + 'Dir' : event;
this._emit(eventName, path);
}
var eventName = info.type === 'directory' ? event + 'Dir' : event;
this._emit(eventName, path);
}.bind(this);
// correct for wrong events emitted
function addOrChange() {
handleEvent(watchedDir.has(item) ? 'change' : 'add');
}
function checkFd() {
fs.open(path, 'r', function(error, fd) {
if (fd) fs.close(fd);
error ? handleEvent('unlink') : addOrChange();
});
}
// correct for wrong events emitted
var wrongEventFlags = [

@@ -136,29 +136,20 @@ 69888, 70400, 71424, 72704, 73472, 131328, 131840, 262912

if (wrongEventFlags.indexOf(flags) !== -1 || info.event === 'unknown') {
if (info.event !== 'add' && info.event !== 'change') {
if (typeof this.options.ignored === 'function') {
fs.stat(path, function(error, stats) {
if (checkIgnored(stats)) return;
if (stats) {
addOrChange();
} else {
handleEvent('unlink');
}
stats ? addOrChange() : handleEvent('unlink');
});
} else {
addOrChange();
checkFd();
}
return;
} else {
switch (info.event) {
case 'created':
case 'modified':
return addOrChange();
case 'deleted':
case 'moved':
return checkFd();
}
}
switch (info.event) {
case 'created':
return addOrChange();
case 'modified':
return addOrChange();
case 'deleted':
return handleEvent('unlink');
case 'moved':
return fs.stat(path, function(error, stats) {
stats ? addOrChange() : handleEvent('unlink');
});
}
}.bind(this);

@@ -177,22 +168,14 @@

fseventsHandler.prototype._symlinkForFsEvents =
function(linkPath, add, pt) {
fseventsHandler.prototype._handleSymlinkForFsEvents =
function(linkPath, pathTransform) {
this._readyCount++;
fs.readlink(linkPath, function(error, linkTarget) {
if (this._handleError(error)) return this._emitReady();
fs.stat(linkTarget, function(error, targetStats) {
if (this._handleError(error)) return this._emitReady();
if (targetStats.isDirectory()) {
this._readyCount++;
this._addToFsEvents(linkTarget, function(path) {
var ds = '.' + sysPath.sep;
return pt(linkTarget && linkTarget !== ds ?
path.replace(linkTarget, linkPath) :
path === ds ? linkPath : sysPath.join(linkPath, path));
});
} else if (targetStats.isFile()) {
add();
this._emitReady();
}
}.bind(this));
this._readyCount++;
this._addToFsEvents(linkTarget, function(path) {
var ds = '.' + sysPath.sep;
return pathTransform(linkTarget && linkTarget !== ds ?
path.replace(linkTarget, linkPath) :
path === ds ? linkPath : sysPath.join(linkPath, path));
});
}.bind(this));

@@ -232,3 +215,3 @@ };

else this._symlinkPaths[entry.fullPath] = true;
this._symlinkForFsEvents(entryPath, addEntry, pathTransform);
this._handleSymlinkForFsEvents(entryPath, pathTransform);
} else {

@@ -235,0 +218,0 @@ addEntry();

'use strict';
var EventEmitter = require('events').EventEmitter;
var fs = require('fs');
var sysPath = require('path');

@@ -5,0 +4,0 @@ var each = require('async-each');

@@ -55,4 +55,5 @@ 'use strict';

if (isWindows && error.code === 'EPERM') {
fs.exists(item, function(exists) {
if (exists) broadcastErr(error);
fs.open(item, 'r', function(err, fd) {
if (fd) fs.close(fd);
if (!err) broadcastErr(error);
});

@@ -59,0 +60,0 @@ } else {

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

@@ -6,0 +6,0 @@ "fs",

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