Skip to content

Commit

Permalink
Build Tooling: Reinstate error handling to build script
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed May 25, 2019
1 parent 6663433 commit c4f908b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 9 additions & 3 deletions bin/packages/build-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,15 @@ const BUILD_TASK_BY_EXTENSION = {
module.exports = async ( file, callback ) => {
const extension = path.extname( file );
const task = BUILD_TASK_BY_EXTENSION[ extension ];
if ( task ) {
await task( file );

if ( ! task ) {
return;
}

callback();
try {
await task( file );
callback();
} catch ( error ) {
callback( error );
}
};
8 changes: 7 additions & 1 deletion bin/packages/build.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-console */

/**
* External dependencies
*/
Expand Down Expand Up @@ -65,9 +67,13 @@ let ended = false,
complete = 0;

stream
.on( 'data', ( file ) => worker( file, () => {
.on( 'data', ( file ) => worker( file, ( error ) => {
onFileComplete();

if ( error ) {
console.log( error );
}

if ( ended && ++complete === files.length ) {
workerFarm.end( worker );
}
Expand Down

0 comments on commit c4f908b

Please sign in to comment.