Skip to content

Commit

Permalink
Small refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Jan 16, 2015
1 parent ee0bf5f commit 8da354f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
7 changes: 4 additions & 3 deletions lib/index.js
Expand Up @@ -119,10 +119,11 @@ FSWatcher.prototype._emit = function(event, target, val1, val2, val3) {
};

FSWatcher.prototype._handleError = function(error) {
var code = error && error.code;
if (error &&
error.code !== 'ENOENT' &&
error.code !== 'ENOTDIR' &&
!(error.code === 'EPERM' && !this.options.ignorePermissionErrors)
code !== 'ENOENT' &&
code !== 'ENOTDIR' &&
!(code === 'EPERM' && !this.options.ignorePermissionErrors)
) this.emit('error', error);
return error || this.closed;
};
Expand Down
8 changes: 4 additions & 4 deletions lib/is-binary.js
Expand Up @@ -3,7 +3,7 @@
var sysPath = require('path');

// Binary file handling code.
var _binExts = [
var extensions = [
'adp', 'au', 'mid', 'mp4a', 'mpga', 'oga', 's3m', 'sil', 'eol', 'dra', 'dts',
'dtshd', 'lvp', 'pya', 'ecelp4800', 'ecelp7470', 'ecelp9600', 'rip', 'weba',
'aac', 'aif', 'caf', 'flac', 'mka', 'm3u', 'wax', 'wma', 'wav', 'xm', 'flac',
Expand All @@ -18,13 +18,13 @@ var _binExts = [
'tar', 'bz2', 'eot', 'ttf', 'woff'
];

var binExts = Object.create(null);
_binExts.forEach(function(ext) { binExts[ext] = true; });
var exts = Object.create(null);
extensions.forEach(function(ext) { exts[ext] = true; });

function isBinaryPath(path) {
var extension = sysPath.extname(path).slice(1);
if (extension === '') return false;
return !!binExts[extension];
return !!exts[extension];
}

module.exports = isBinaryPath;
11 changes: 6 additions & 5 deletions lib/nodefs-handler.js
Expand Up @@ -260,27 +260,28 @@ function(dir, stats, initialAdd, depth, target, globFilter, callback) {
var item = entry.path;
current.push(item);
var path = sysPath.join(directory, item);
var full = entry.fullPath;

if (entry.stat.isSymbolicLink()) {
if (!_this.options.followSymlinks) {
_this._readyCount++;
fs.realpath(path, function(error, linkPath) {
if (previous.has(item)) {
if (_this._symlinkPaths[entry.fullPath] !== linkPath) {
_this._symlinkPaths[entry.fullPath] = linkPath;
if (_this._symlinkPaths[full] !== linkPath) {
_this._symlinkPaths[full] = linkPath;
_this._emit('change', path, entry.stat);
}
} else {
previous.add(item);
_this._symlinkPaths[entry.fullPath] = linkPath;
_this._symlinkPaths[full] = linkPath;
_this._emit('add', path, entry.stat);
}
_this._emitReady();
});
return;
}
if (_this._symlinkPaths[entry.fullPath]) return;
else _this._symlinkPaths[entry.fullPath] = true;
if (_this._symlinkPaths[full]) return;
else _this._symlinkPaths[full] = true;
}

// Files that present in current directory snapshot
Expand Down

3 comments on commit 8da354f

@paulmillr
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shit...this broke some code

@es128
Copy link
Collaborator

@es128 es128 commented on 8da354f Jan 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it didn't. fs.watch on OS X really sucks and breaks tests sporadically by spewing extra events randomly.

@es128
Copy link
Collaborator

@es128 es128 commented on 8da354f Jan 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db1924e is intended to address this

Please sign in to comment.