Skip to content

Commit

Permalink
refactor(cli): run readme and markdown generation in parallel, load s…
Browse files Browse the repository at this point in the history
…chemas only once
  • Loading branch information
trieloff committed Dec 11, 2019
1 parent c9fbcdf commit 3a45c6a
Showing 1 changed file with 28 additions and 40 deletions.
68 changes: 28 additions & 40 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,50 +107,42 @@ const schemaloader = loader();
readdirp.promise(schemaPath, { root: schemaPath, fileFilter: `*.${schemaExtension}` })
// then collect data about the schemas and turn everything into a big object
.then((schemas) => {
pipe(
console.log('loading schemas');
return pipe(
schemas,
map(schema => schema.fullPath),
// eslint-disable-next-line import/no-dynamic-require, global-require
map(path => schemaloader(require(path), path)),
// find contained schemas
traverse,
// build readme
readme({
readme: !argv.n,
}),

writereadme({
readme: !argv.n,
out: argv.o,
info,
error,
debug,
meta: argv.m,
}),
);
})

// generate Markdown
return pipe(
.then(schemas => Promise.all([
(() => {
if (argv.n) {
return pipe(
schemas,
// build readme
readme({
readme: !argv.n,
}),

writereadme({
readme: !argv.n,
out: argv.o,
info,
error,
debug,
meta: argv.m,
}),
);
}
return null;
})(),
(() => pipe(
schemas,
map(schema => schema.fullPath),
// eslint-disable-next-line import/no-dynamic-require, global-require
map(path => schemaloader(require(path), path)),
// find contained schemas
traverse,

// remove pure ref schemas
// filterRefs,

/*
(x) => {
console.log('emitting');
const y = list(x);
console.log(y);
return y;
},
*/


// generate Markdown ASTs
build({
header: argv.h,
Expand All @@ -168,9 +160,5 @@ readdirp.promise(schemaPath, { root: schemaPath, fileFilter: `*.${schemaExtensio
debug,
meta: argv.m,
}),
);
})

.then(() => {
// console.log('allschemas', schemas);
});
))(),
]));

0 comments on commit 3a45c6a

Please sign in to comment.