Skip to content

Commit

Permalink
Merge pull request #49 from unexpectedjs/require-via-evaldown
Browse files Browse the repository at this point in the history
Send the require option directly to evaldown and allow a config file.
  • Loading branch information
alexjeffburke authored Aug 23, 2020
2 parents 8d01ea7 + 875cd3a commit 031fcd5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 10 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,6 @@ function addTypeToIndex(typeIndex, type) {
}

module.exports = async function generate(options) {
if (options.require) {
var moduleNames = options.require;
if (!Array.isArray(moduleNames)) {
moduleNames = [moduleNames];
}
moduleNames.forEach(function(moduleName) {
if (/^[./]/.test(moduleName)) {
moduleName = path.resolve(process.cwd(), moduleName);
}
require(moduleName);
});
}

var localExpect = createExpect(options);

function sortTypesByHierarchy(assertionsByType) {
Expand Down Expand Up @@ -141,7 +128,17 @@ module.exports = async function generate(options) {
var output = options.output || 'site-build';
var tmpOutput = path.join(os.tmpdir(), 'udsg', String(process.pid));

var config;
try {
config = require(path.join(cwd, options.config));
} catch (e) {
config = null;
}
options = { ...config, ...options };
options = { ...options, ...(await Evaldown.decodeOptions(cwd, options)) };

const statsObject = await new Evaldown({
...options,
commentMarker: 'unexpected-markdown',
outputFormat: 'inlined',
sourcePath: documentation,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"autoprefixer": "9.8.6",
"debug": "4.1.0",
"ejs": "2.5.6",
"evaldown": "^1.0.0",
"evaldown": "^1.4.0",
"gh-pages": "2.0.1",
"glob": "7.1.6",
"lodash": "4.17.19",
Expand Down

0 comments on commit 031fcd5

Please sign in to comment.