Skip to content

Commit

Permalink
make onCompilationComplete() hook async
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Sep 29, 2020
1 parent bc94795 commit c0fe83e
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions packages/kbn-ui-shared-deps/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ run(
);

/** @param {webpack.Stats} stats */
const onCompilationComplete = (stats) => {
const onCompilationComplete = async (stats) => {
const took = Math.round((stats.endTime - stats.startTime) / 1000);

if (!stats.hasErrors() && !stats.hasWarnings()) {
Expand Down Expand Up @@ -69,10 +69,7 @@ run(

log.debug('metrics:', metrics);

reporter.metrics(metrics).catch((error) => {
log.error('Failed to report stats with CiStatsReporter');
log.error(error);
});
await reporter.metrics(metrics);
}

log.success(`webpack completed in about ${took} seconds`);
Expand All @@ -89,11 +86,9 @@ run(

if (flags.watch) {
compiler.hooks.done.tap('report on stats', (stats) => {
try {
onCompilationComplete(stats);
} catch (error) {
onCompilationComplete(stats).catch((error) => {
log.error(error.message);
}
});
});

compiler.hooks.watchRun.tap('report on start', () => {
Expand All @@ -116,7 +111,7 @@ run(
return;
}

onCompilationComplete(
await onCompilationComplete(
await new Promise((resolve, reject) => {
compiler.run((error, stats) => {
if (error) {
Expand Down

0 comments on commit c0fe83e

Please sign in to comment.