Skip to content

Commit

Permalink
feat: add support for node resolve algo
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias authored and tmcw committed Oct 24, 2018
1 parent a033547 commit ddd675d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions declarations/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type DocumentationConfig = {
noReferenceLinks?: boolean,
markdownToc?: boolean,
documentExported?: boolean,
resolve?: string,
hljs?: Object
};

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
"doc": "node ./bin/documentation.js build src/index.js -f md --access=public > docs/NODE_API.md",
"self-lint": "node ./bin/documentation.js lint src",
"test": "npm run build && eslint . && flow check && jest",
"test2": "npm run build && flow check && jest",
"test-ci": "npm run build && eslint . && flow check && jest --runInBand"
},
"jest": {
Expand Down
5 changes: 5 additions & 0 deletions src/commands/shared_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ module.exports.sharedInputOptions = {
describe: 'The order to sort the documentation',
choices: ['source', 'alpha'],
default: 'source'
},
resolve: {
describe: 'Dependency resolution algorithm.',
choices: ['browser', 'node'],
default: 'browser'
}
};

Expand Down
12 changes: 7 additions & 5 deletions src/input/dependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ function dependencyStream(
})
],
postFilter: moduleFilters.externals(indexes, config),
resolve: (id, opts, cb) => {
const r = require('resolve');
opts.basedir = path.dirname(opts.filename);
r(id, opts, cb);
}
resolve:
config.resolve === 'node' &&
((id, opts, cb) => {
const r = require('resolve');
opts.basedir = path.dirname(opts.filename);
r(id, opts, cb);
})
});
smartGlob(indexes, config.parseExtension).forEach(index => {
md.write(path.resolve(index));
Expand Down

0 comments on commit ddd675d

Please sign in to comment.