Skip to content

Commit

Permalink
try optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
amasad committed Jun 25, 2017
1 parent 803407c commit 402a760
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/fsevents_watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ var fs = require('fs');
var path = require('path');
var common = require('./common');
var EventEmitter = require('events').EventEmitter;
var fsevents = require('fsevents');
var fsevents;

try {
fsevents = require('fsevents');
} catch (e) {
// Ignore.
}

/**
* Constants
Expand All @@ -31,6 +37,12 @@ module.exports = FSEventsWatcher;
*/

function FSEventsWatcher(dir, opts) {
if (!fsevents) {
throw new Error(
'`fsevents` unavailable (this watcher can only be used on Darwin)'
);
}

common.assignOptions(this, opts);

this.root = path.resolve(dir);
Expand Down

0 comments on commit 402a760

Please sign in to comment.