diff --git a/CHANGELOG.md b/CHANGELOG.md index c8479a4..3d7bb2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.1.0 + +* Add `external` option that allows the user to whitelist specific external + modules to be included in with documentation. + ## 1.0.7 * Fixes sorting order of documentation diff --git a/index.js b/index.js index fb5b1b0..cfe46c7 100644 --- a/index.js +++ b/index.js @@ -20,6 +20,9 @@ var mdeps = require('module-deps'), * @name documentation * @param {Array|String} indexes files to process * @param {Object} options options + * @param {Array} options.external a string regex / glob match pattern + * that defines what external modules will be whitelisted and included in the + * generated documentation. * @return {Object} stream of output */ module.exports = function (indexes, options) { diff --git a/lib/module-filters.js b/lib/module-filters.js index e5ca4ee..7951c48 100644 --- a/lib/module-filters.js +++ b/lib/module-filters.js @@ -30,6 +30,8 @@ module.exports = { // grab the path of the top-level node_modules directory. var topNodeModules = path.join(path.dirname(index), 'node_modules'); return function matchGlob(file, pkg) { + // if a module is not found, don't include it. + if (!file || !pkg) return false; // if package.json specifies a 'main' script, strip that path off // the file to get the module's directory. // otherwise, just use the dirname of the file. diff --git a/test/fixture/external.input.js b/test/fixture/external.input.js index c270a6b..9d7bf6a 100644 --- a/test/fixture/external.input.js +++ b/test/fixture/external.input.js @@ -1,2 +1,3 @@ require('external'); require('external2'); +require('module-not-found');