feat: tie in challenge parser
This commit is contained in:
23
tools/challenge-md-parser/tests-to-data.js
Normal file
23
tools/challenge-md-parser/tests-to-data.js
Normal file
@ -0,0 +1,23 @@
|
||||
const visit = require('unist-util-visit');
|
||||
const YAML = require('js-yaml');
|
||||
|
||||
function plugin() {
|
||||
return transformer;
|
||||
|
||||
function transformer(tree, file) {
|
||||
visit(tree, 'code', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
const { lang, value } = node;
|
||||
if (lang === 'yml') {
|
||||
const tests = YAML.load(value);
|
||||
file.data = {
|
||||
...file.data,
|
||||
...tests
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = plugin;
|
Reference in New Issue
Block a user