Skip to content

Commit

Permalink
Do not fail if optional dependencies not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Apr 14, 2018
1 parent 3f3e4e7 commit 890900e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
'use strict';

module.exports = {
Diff: require('./diff'),
generateDiff: require('./generate'),
Diff: require('./diff')
};

try {
// Optional dependency
module.exports.generateDiff = require('./generate');
} catch (e) {
// istanbul ignore next
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}
// istanbul ignore next
Object.defineProperty(module.exports, 'generateDiff', { get() { throw e; } });
}

0 comments on commit 890900e

Please sign in to comment.