Skip to content

Commit

Permalink
Merge branch 'dev' into npm
Browse files Browse the repository at this point in the history
  • Loading branch information
e2tha-e committed May 23, 2019
2 parents 63c3a8b + 5f6eb29 commit 77fdea8
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ branches:
- npm
- v1-lts
# After releasing, bump to next anticpated version.
- v1-lts@1.7.8
- v1-lts@1.7.9
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Chokidar Changelog

### 1.7.9
* Fixed bug that disabled fsevents for wrong macOS versions

### 1.7.8
* Disabling fsevents for macOS versions < Sierra

### 1.7.7
* Disabling fsevents for macOS versions < Sierra
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ branches:
- npm
- v1-lts
# After releasing, bump to next anticpated version.
- v1-lts@1.7.8
- v1-lts@1.7.9

skip_tags: true
21 changes: 15 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,24 @@ function FSWatcher(_opts) {
if (undef('disableGlobbing')) opts.disableGlobbing = false;
this.enableBinaryInterval = opts.binaryInterval !== opts.interval;

// Enable fsevents on OS X when polling isn't explicitly enabled.
if (undef('useFsEvents')) opts.useFsEvents = !opts.usePolling;
// Darwin major version 15 is macOS 10.11 El Capitan.
// fsevents does not work in 10.11 El Capitan and lower.
/* istanbul ignore next */
if (isDarwin && osMajor <= 15) {
opts.useFsEvents = false;

// If we can't use fsevents, ensure the options reflect it's disabled.
if (!FsEventsHandler.canUse()) opts.useFsEvents = false;
} else if (!FsEventsHandler.canUse()) {
opts.useFsEvents = false;

// Darwin major version 15 is macOS 10.11 El Capitan.
// fsevents does not work in 10.11 El Capitan and lower.
if (isDarwin && osMajor > 15) opts.useFsEvents = false;
// Enable fsevents on OS X when polling isn't explicitly enabled.
} else if (undef('useFsEvents')) {
opts.useFsEvents = !opts.usePolling;
}

// Use polling on Mac if not using fsevents.
// Other platforms use non-polling fs.watch.
/* istanbul ignore if */
if (undef('usePolling') && !opts.useFsEvents) {
opts.usePolling = isDarwin;
}
Expand Down Expand Up @@ -225,6 +231,7 @@ FSWatcher.prototype._emit = function(event_, path_, val1, val2, val3) {
return this;
}

/* istanbul ignore if */
if (this.options.atomic) {
if (event === 'unlink') {
this._pendingUnlinks[path] = args;
Expand Down Expand Up @@ -263,6 +270,7 @@ FSWatcher.prototype._emit = function(event_, path_, val1, val2, val3) {

if (awf && (event === 'add' || event === 'change') && this._readyEmitted) {
var awfEmit = function(err, stats) {
/* istanbul ignore if */
if (err) {
event = args[0] = 'error';
args[1] = err;
Expand Down Expand Up @@ -314,6 +322,7 @@ FSWatcher.prototype._emit = function(event_, path_, val1, val2, val3) {
FSWatcher.prototype._handleError = function(error) {
var code = error && error.code;
var ipe = this.options.ignorePermissionErrors;
/* istanbul ignore if */
if (error &&
code !== 'ENOENT' &&
code !== 'ENOTDIR' &&
Expand Down
3 changes: 3 additions & 0 deletions lib/fsevents-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var fs = require('fs');
var sysPath = require('path');
var readdirp = require('readdirp');
var fsevents;
/* istanbul ignore next */
try { fsevents = require('fsevents'); } catch (error) {
// eslint-disable-next-line no-console
if (process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR) console.error(error);
Expand Down Expand Up @@ -222,6 +223,7 @@ function(watchPath, realPath, transform, globFilter) {
}
function checkFd() {
fs.open(path, 'r', function(error, fd) {
/* istanbul ignore if */
if (error) {
if (error.code !== 'EACCES') handleEvent('unlink');
else addOrChange();
Expand All @@ -244,6 +246,7 @@ function(watchPath, realPath, transform, globFilter) {
if (stats) {
addOrChange();
} else {
/* istanbul ignore next */
handleEvent('unlink');
}
});
Expand Down
4 changes: 4 additions & 0 deletions lib/nodefs-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function createFsWatchInstance(path, options, oldStats, chokidarInstance, listen
try {
return fs.watch(path, options, handleEvent);
} catch (error) {
/* istanbul ignore next */
errHandler(error);
}
}
Expand Down Expand Up @@ -116,6 +117,7 @@ function setFsWatchListener(path, fullPath, options, stats, chokidarInstance, ha
);
if (!watcher) return;
var broadcastErr = fsWatchBroadcast.bind(null, fullPath, 'errHandlers');
/* istanbul ignore next */
watcher.on('error', function(error) {
container.watcherUnusable = true; // documented since Node 10.4.1
// Workaround for https://github.com/nodejs/node-v0.x-archive/issues/4337
Expand Down Expand Up @@ -313,6 +315,8 @@ function(file, stats, initialAdd, chokidarInstance, callback) {
}

if (callback) callback();

/* istabul ignore next */
return closer;
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@electric-eloquence/chokidar",
"description": "A neat wrapper around node.js fs.watch / fs.watchFile / fsevents.",
"version": "1.7.8",
"version": "1.7.9",
"keywords": [
"fs",
"watch",
Expand Down

0 comments on commit 77fdea8

Please sign in to comment.