New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@electric-eloquence/chokidar

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@electric-eloquence/chokidar - npm Package Compare versions

Comparing version 1.7.9 to 1.7.10

5

CHANGELOG.md
# Chokidar Changelog
### 1.7.10
* Checking that macOS > El Capitan in FsEventsHandler.canUse instead of index.js
* Updated anymatch to major version 3
* Broad updates to dependencies
### 1.7.9

@@ -4,0 +9,0 @@ * Fixed bug that disabled fsevents for wrong macOS versions

70

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

@@ -11,3 +11,2 @@

var isGlob = require('is-glob');
var isAbsolute = require('path-is-absolute');
var inherits = require('inherits');

@@ -19,5 +18,2 @@ var slash = require('slash');

var osMajor = parseInt(os.release().split('.')[0], 10);
var isDarwin = process.platform === 'darwin';
var slashStringOrArray = function(stringOrArray) {

@@ -37,2 +33,3 @@ var slashed;

} else {
/* istanbul ignore next */
slashed = stringOrArray;

@@ -51,2 +48,3 @@ }

}
/* istanbul ignore if */
if (arguments.length > 2) {

@@ -57,3 +55,3 @@ for (var i = 2; i < arguments.length; i++) {

}
return anymatch.apply(null, argsNew);
return anymatch.apply(null, argsNew, {strictSlashes: true});
};

@@ -130,12 +128,7 @@

// Darwin major version 15 is macOS 10.11 El Capitan.
// fsevents does not work in 10.11 El Capitan and lower.
// If we can't use fsevents, ensure the options reflect it's disabled.
/* istanbul ignore next */
if (isDarwin && osMajor <= 15) {
if (!FsEventsHandler.canUse()) {
opts.useFsEvents = false;
// If we can't use fsevents, ensure the options reflect it's disabled.
} else if (!FsEventsHandler.canUse()) {
opts.useFsEvents = false;
// Enable fsevents on OS X when polling isn't explicitly enabled.

@@ -150,3 +143,3 @@ } else if (undef('useFsEvents')) {

if (undef('usePolling') && !opts.useFsEvents) {
opts.usePolling = isDarwin;
opts.usePolling = process.platform === 'darwin';
}

@@ -187,3 +180,2 @@

}
if (opts.ignored) opts.ignored = arrify(opts.ignored);

@@ -382,3 +374,3 @@ this._isntIgnored = function(path, stat) {

var fullPath = path;
if (this.options.cwd && !isAbsolute(path)) {
if (this.options.cwd && !sysPath.isAbsolute(path)) {
fullPath = sysPath.join(this.options.cwd, path);

@@ -391,2 +383,3 @@ }

fs.stat(fullPath, function(err, curStat) {
/* istanbul ignore if */
if (err || !(path in this._pendingWrites)) {

@@ -447,15 +440,16 @@ if (err && err.code !== 'ENOENT') awfEmit(err);

var cwd = this.options.cwd;
var ignored = this.options.ignored;
if (cwd && ignored) {
ignored = ignored.map(function(path) {
var ignored;
if (cwd) {
ignored = arrify(this.options.ignored).map(function(path) {
if (typeof path !== 'string') return path;
return isAbsolute(path) ? path : sysPath.join(cwd, path);
return sysPath.isAbsolute(path) ? path : sysPath.join(cwd, path);
});
} else {
ignored = arrify(this.options.ignored);
}
var paths = arrify(ignored)
.filter(function(path) {
return typeof path === 'string' && !isGlob(path);
}).map(function(path) {
return path + '/**';
});
var paths = ignored.filter(function(path) {
return typeof path === 'string' && !isGlob(slash(path));
}).map(function(path) {
return path + '/**';
});
this._userIgnored = anymatchSlashed(

@@ -480,3 +474,3 @@ this._globIgnored.concat(ignored).concat(paths)

var path = path_.replace(replacerRe, '');
var watchPath = depth || this.options.disableGlobbing || !isGlob(path) ? path : globParent(path);
var watchPath = depth || this.options.disableGlobbing || !isGlob(slash(path)) ? path : globParent(path);
var fullWatchPath = sysPath.resolve(watchPath);

@@ -531,11 +525,13 @@ var hasGlob = watchPath !== path;

}
return !unmatchedGlob && this._isntIgnored(entryPath(entry), entry.stat);
return !unmatchedGlob && this._isntIgnored(entryPath(entry), entry.stats);
}.bind(this);
var filterPath = function(entry) {
if (entry.stat && entry.stat.isSymbolicLink()) return filterDir(entry);
if (entry.stats && entry.stats.isSymbolicLink()) {
return filterDir(entry);
}
var resolvedPath = entryPath(entry);
return (!hasGlob || globFilter(resolvedPath)) &&
this._isntIgnored(resolvedPath, entry.stat) &&
(this.options.ignorePermissionErrors || this._hasReadPermissions(entry.stat));
this._isntIgnored(resolvedPath, entry.stats) &&
(this.options.ignorePermissionErrors || this._hasReadPermissions(entry.stats));
}.bind(this);

@@ -596,3 +592,9 @@

FSWatcher.prototype._hasReadPermissions = function(stats) {
return Boolean(4 & parseInt(((stats && stats.mode) & 0x1ff).toString(8)[0], 10));
if (this.options.ignorePermissionErrors) return true;
// stats.mode may be bigint
var md = stats && Number.parseInt(stats.mode, 10);
var st = md & parseInt('777', 8);
var it = Number.parseInt(st.toString(8)[0], 10);
return Boolean(4 & it);
};

@@ -690,3 +692,3 @@

var absPath;
if (isAbsolute(path)) {
if (sysPath.isAbsolute(path)) {
absPath = path;

@@ -759,3 +761,3 @@ } else if (path[0] === '!') {

var path = path_;
if (!isAbsolute(path) && !this._closers[path]) {
if (!sysPath.isAbsolute(path) && !this._closers[path]) {
if (this.options.cwd) path = sysPath.join(this.options.cwd, path);

@@ -762,0 +764,0 @@ path = sysPath.resolve(path);

'use strict';
var fs = require('fs');
var os = require('os');
var sysPath = require('path');
var readdirp = require('readdirp');
var fsevents;
var osMajor = parseInt(os.release().split('.')[0]);
/* istanbul ignore next */

@@ -88,4 +93,4 @@ try { fsevents = require('fsevents'); } catch (error) {

var info = fsevents.getInfo(fullPath, flags);
watchContainer.listeners.forEach(function(listener) {
listener(fullPath, flags, info);
watchContainer.listeners.forEach(function(wcListener) {
wcListener(fullPath, flags, info);
});

@@ -133,2 +138,9 @@ watchContainer.rawEmitters.forEach(function(emitter) {

function canUse() {
// Darwin major version 15 is macOS 10.11 El Capitan
// fsevents does not work in 10.11 El Capitan and lower
/* istanbul ignore if */
if (process.platform === 'darwin' && osMajor <= 15) {
return false;
}
return fsevents && Object.keys(FSEventsWatchers).length < 128;

@@ -165,3 +177,3 @@ }

if (
typeof this.options.depth !== 'undefined' &&
typeof this.options.depth === 'number' &&
depth(fullPath, realPath) > this.options.depth

@@ -208,3 +220,3 @@ ) return;

var curDepth;
if (typeof this.options.depth !== 'undefined') {
if (typeof this.options.depth === 'number') {
curDepth = depth(fullPath, realPath) + 1;

@@ -243,5 +255,8 @@ }

// correct for wrong events emitted
// recreating consistent flags for testing is very difficult
// is inconsistently covered by "allows regex fn ignores" test
var wrongEventFlags = [
69888, 70400, 71424, 72704, 73472, 131328, 131840, 262912
];
/* istanbul ignore if */
if (wrongEventFlags.indexOf(flags) !== -1 || info.event === 'unknown') {

@@ -254,3 +269,2 @@ if (typeof this.options.ignored === 'function') {

} else {
/* istanbul ignore next */
handleEvent('unlink');

@@ -302,2 +316,3 @@ }

fs.realpath(linkPath, function(error, linkTarget) {
/* istanbul ignore if */
if (this._handleError(error) || this._isIgnored(linkTarget)) {

@@ -314,2 +329,3 @@ return this._emitReady();

var aliasedPath = linkPath;
/* istanbul ignore else */
if (linkTarget && linkTarget !== dotSlash) {

@@ -371,15 +387,16 @@ aliasedPath = path.replace(linkTarget, linkPath);

// don't recurse further if it would exceed depth setting
if (priorDepth && priorDepth > this.options.depth) return;
if (priorDepth && typeof this.options.depth === 'number' && priorDepth > this.options.depth) return;
// scan the contents of the dir
readdirp({
root: wh.watchPath,
entryType: 'all',
readdirp(wh.watchPath, {
fileFilter: wh.filterPath,
directoryFilter: wh.filterDir,
lstat: true,
depth: this.options.depth - (priorDepth || 0)
depth:
typeof this.options.depth === 'number' ? this.options.depth - (priorDepth || 0) : Number.MAX_SAFE_INTEGER,
type: 'all',
alwaysStat: true,
lstat: true
}).on('data', function(entry) {
// need to check filterPath on dirs b/c filterDir is less restrictive
if (entry.stat.isDirectory() && !wh.filterPath(entry)) return;
if (entry.stats.isDirectory() && !wh.filterPath(entry)) return;

@@ -389,7 +406,7 @@ var joinedPath = sysPath.join(wh.watchPath, entry.path);

if (wh.followSymlinks && entry.stat.isSymbolicLink()) {
if (wh.followSymlinks && entry.stats.isSymbolicLink()) {
// preserve the current depth here since it can't be derived from
// real paths past the symlink
var curDepth;
if (typeof this.options.depth !== 'undefined') {
if (typeof this.options.depth === 'number') {
curDepth = depth(joinedPath, sysPath.resolve(wh.watchPath)) + 1;

@@ -400,3 +417,3 @@ }

} else {
emitAdd(joinedPath, entry.stat);
emitAdd(joinedPath, entry.stats);
}

@@ -403,0 +420,0 @@ }.bind(this)).on('error', function() {

@@ -184,2 +184,3 @@ 'use strict';

var rawEmitters = [];
/* istanbul ignore if */
if (

@@ -333,5 +334,5 @@ container && (

NodeFsHandler.prototype._handleSymlink =
function(entry, directory, path, item) {
var full = entry.fullPath;
function(entry, directory, resolvedPath, item) {
var dir = this._getWatchedDir(directory);
var path = sysPath.join(directory, item);

@@ -341,15 +342,13 @@ if (!this.options.followSymlinks) {

this._readyCount++;
fs.realpath(path, function(error, linkPath) {
if (dir.has(item)) {
if (this._symlinkPaths[full] !== linkPath) {
this._symlinkPaths[full] = linkPath;
this._emit('change', path, entry.stat);
}
} else {
dir.add(item);
this._symlinkPaths[full] = linkPath;
this._emit('add', path, entry.stat);
if (dir.has(item)) {
if (this._symlinkPaths[resolvedPath] !== resolvedPath) {
this._symlinkPaths[resolvedPath] = resolvedPath;
this._emit('change', path, entry.stats);
}
this._emitReady();
}.bind(this));
} else {
dir.add(item);
this._symlinkPaths[resolvedPath] = resolvedPath;
this._emit('add', path, entry.stats);
}
this._emitReady();
return true;

@@ -359,4 +358,4 @@ }

// don't follow the same symlink more than once
if (this._symlinkPaths[full]) return true;
else this._symlinkPaths[full] = true;
if (this._symlinkPaths[resolvedPath]) return true;
else this._symlinkPaths[resolvedPath] = true;
};

@@ -402,8 +401,8 @@

readdirp({
root: directory,
entryType: 'all',
readdirp(directory, {
fileFilter: wh.filterPath,
directoryFilter: wh.filterDir,
depth: 0,
type: 'all',
alwaysStat: true,
lstat: true

@@ -413,6 +412,6 @@ }).on('data', function(entry) {

var path = sysPath.join(directory, item);
var resolvedPath = fs.realpathSync(path);
current.push(item);
if (entry.stat.isSymbolicLink() &&
this._handleSymlink(entry, directory, path, item)) return;
if (entry.stats.isSymbolicLink() && this._handleSymlink(entry, directory, resolvedPath, item)) return;

@@ -502,2 +501,4 @@ // Files that present in current directory snapshot

if (this._handleError(error)) return callback(null, path);
// should not have made it past the previous _isIgnored check
/* istanbul ignore if */
if (this._isIgnored(wh.watchPath, stats)) {

@@ -504,0 +505,0 @@ ready();

{
"name": "@electric-eloquence/chokidar",
"description": "A neat wrapper around node.js fs.watch / fs.watchFile / fsevents.",
"version": "1.7.9",
"version": "1.7.10",
"keywords": [

@@ -40,7 +40,7 @@ "fs",

"coveralls": "3.x",
"eslint": "5.x",
"graceful-fs": "^4.1.15",
"eslint": "6.x",
"graceful-fs": "^4.2.3",
"mocha": "6.x",
"nyc": "14.x",
"rimraf": "^2.6.2",
"rimraf": "^3.0.0",
"sinon": "7.x",

@@ -50,15 +50,14 @@ "sinon-chai": "3.x"

"optionalDependencies": {
"fsevents": "^2.0.6"
"fsevents": "^2.1.1"
},
"dependencies": {
"anymatch": "^2.0.0",
"async-each": "^1.0.0",
"glob-parent": "^2.0.0",
"inherits": "^2.0.1",
"is-binary-path": "^1.0.0",
"is-glob": "^2.0.0",
"path-is-absolute": "^1.0.0",
"readdirp": "^2.0.0",
"slash": "^2.0.0"
"anymatch": "^3.1.1",
"async-each": "^1.0.3",
"glob-parent": "^5.1.0",
"inherits": "^2.0.4",
"is-binary-path": "^2.1.0",
"is-glob": "^4.0.1",
"readdirp": "^3.2.0",
"slash": "^3.0.0"
}
}

@@ -9,3 +9,3 @@ # Chokidar

[![Coverage Status][coveralls-image]][coveralls-url]
![Node Version][version-image]
![Node Version][node-version-image]
[![License][license-image]][license-url]

@@ -18,14 +18,2 @@

## Install
```shell
npm install --save @electric-eloquence/chokidar
```
## Use
```javascript
var chokidar = require('@electric-eloquence/chokidar');
```
## Why Chokidar?

@@ -70,3 +58,3 @@

npm install @electric-eloquence/chokidar --save
npm install @electric-eloquence/chokidar

@@ -336,14 +324,14 @@ Then `require` and use it in your code:

[travis-image]: https://img.shields.io/travis/electric-eloquence/chokidar.svg?label=mac%20%26%20linux
[travis-image]: https://img.shields.io/travis/electric-eloquence/chokidar/v1-lts.svg?label=mac%20%26%20linux
[travis-url]: https://travis-ci.org/electric-eloquence/chokidar
[appveyor-image]: https://img.shields.io/appveyor/ci/e2tha-e/chokidar.svg?label=windows
[appveyor-image]: https://img.shields.io/appveyor/ci/e2tha-e/chokidar/v1-lts.svg?label=windows
[appveyor-url]: https://ci.appveyor.com/project/e2tha-e/chokidar
[coveralls-image]: https://coveralls.io/repos/github/electric-eloquence/chokidar/badge.svg?branch=v1-lts
[coveralls-image]: https://img.shields.io/coveralls/electric-eloquence/chokidar/v1-lts.svg
[coveralls-url]: https://coveralls.io/github/electric-eloquence/chokidar?branch=v1-lts
[version-image]: https://img.shields.io/node/v/@electric-eloquence/chokidar.svg
[node-version-image]: https://img.shields.io/node/v/@electric-eloquence/chokidar.svg
[license-image]: https://img.shields.io/github/license/electric-eloquence/chokidar.svg
[license-url]: https://raw.githubusercontent.com/electric-eloquence/chokidar/v1-lts/LICENSE

Sorry, the diff of this file is not supported yet

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