From 7f88d26a60208d40505a6f4e4fa5b6db7cdbe313 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Wed, 4 Jul 2018 13:30:05 -0400 Subject: [PATCH] Pass { childProcess, runLog } into post-startup callback function. --- tools/isobuild/bundler.js | 13 ++++++++++--- tools/runners/run-app.js | 9 +++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/isobuild/bundler.js b/tools/isobuild/bundler.js index b17a4d895d..8de97ee870 100644 --- a/tools/isobuild/bundler.js +++ b/tools/isobuild/bundler.js @@ -3166,12 +3166,17 @@ function bundle({ // If we have a previous builder for this arch, and it's an arch // that we can safely build later (e.g. web.browser.legacy), then // schedule it to be built after the others. - postStartupCallbacks.push(childProcess => { + postStartupCallbacks.push(({ + childProcess, + runLog, + }) => { const start = +new Date; // Build and write the target in one step. writeClientTarget(makeClientTarget(app, arch, { minifiers })); + // Return a Promise so that the caller has to wait for the + // childProcess.send to complete. return new Promise((resolve, reject) => { // Let the webapp package running in the child process know it // should regenerate the client program for this arch. @@ -3183,13 +3188,15 @@ function bundle({ if (error) { reject(error); } else { - resolve(`Finished delayed build of ${arch} in ${ + runLog.log(`Finished delayed build of ${arch} in ${ new Date - start - }ms`); + }ms`, { arrow: true }); + resolve(); } }); }); }); + } else { // Otherwise make the client target now, and write it below. targets[arch] = makeClientTarget(app, arch, {minifiers}); diff --git a/tools/runners/run-app.js b/tools/runners/run-app.js index ec1883dd63..ebe876416b 100644 --- a/tools/runners/run-app.js +++ b/tools/runners/run-app.js @@ -796,10 +796,11 @@ _.extend(AppRunner.prototype, { while (callbacks.length > 0) { const fn = callbacks.shift(); try { - const message = Promise.await(fn(appProcess.proc)); - if (message) { - runLog.log(message, { arrow: true }); - } + Promise.await(fn({ + // Miscellany that the callback might find useful. + childProcess: appProcess.proc, + runLog, + })); } catch (error) { buildmessage.error(error); }