Skip to content

Commit

Permalink
docgen: Generate package docs in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Mar 6, 2019
1 parent 078041b commit 38c0d76
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bin/update-readmes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node

const path = require( 'path' );
const childProcess = require( 'child_process' );
const { promisify } = require( 'util' );
const spawn = promisify( require( 'child_process' ).spawn );

const packages = [
//'a11y',
Expand Down Expand Up @@ -34,24 +35,23 @@ const packages = [
//'wordcount',
];

let aggregatedExitCode = 0;
packages.forEach( ( packageName ) => {
Promise.all( packages.map( async ( packageName ) => {
const args = [
`packages/${ packageName }/src/index.js`,
`--output packages/${ packageName }/README.md`,
'--to-token',
'--ignore "unstable|experimental"',
];
const pathToDocGen = path.join( __dirname, '..', 'node_modules', '.bin', 'docgen' );
const { status, stderr } = childProcess.spawnSync(
const { status, stderr } = await spawn(
pathToDocGen,
args,
{ shell: true },
);
if ( status !== 0 ) {
aggregatedExitCode = status;
process.stderr.write( `${ stderr }\n` );
throw stderr.toString();
}
} ) ).catch( ( error ) => {
process.stderr.write( `${ error }\n` );
process.exit( 1 );
} );

process.exit( aggregatedExitCode );

0 comments on commit 38c0d76

Please sign in to comment.