From 43038744d9e275bb46866bbc752bc317e7dbb3e0 Mon Sep 17 00:00:00 2001 From: matheusccastro Date: Sat, 6 May 2023 11:21:38 -0300 Subject: [PATCH 1/3] Add missing `awaits` to cordova setup. --- tools/cli/commands-cordova.js | 4 ++-- tools/cordova/builder.js | 12 ++++++------ tools/cordova/index.js | 4 ++-- tools/cordova/project.js | 14 +++++--------- tools/cordova/run-targets.js | 4 ++-- tools/cordova/runner.js | 1 - 6 files changed, 17 insertions(+), 22 deletions(-) diff --git a/tools/cli/commands-cordova.js b/tools/cli/commands-cordova.js index 52cc2f09f6..1b4557aecc 100644 --- a/tools/cli/commands-cordova.js +++ b/tools/cli/commands-cordova.js @@ -148,8 +148,8 @@ main.registerCommand({ name: 'list-platforms', requiresApp: true, catalogRefresh: new catalog.Refresh.Never() -}, function (options) { - const projectContext = createProjectContext(options.appDir); +}, async function (options) { + const projectContext = await createProjectContext(options.appDir); const installedPlatforms = projectContext.platformList.getPlatforms(); diff --git a/tools/cordova/builder.js b/tools/cordova/builder.js index 8f42539aa4..7c6c9fb75e 100644 --- a/tools/cordova/builder.js +++ b/tools/cordova/builder.js @@ -245,11 +245,11 @@ export class CordovaBuilder { if (files.exists(controlFilePath)) { Console.debug('Processing mobile-config.js'); - await buildmessage.enterJob({ title: `processing mobile-config.js` }, () => { + await buildmessage.enterJob({ title: `processing mobile-config.js` }, async () => { const code = files.readFile(controlFilePath, 'utf8'); try { - files.runJavaScript(code, { + await files.runJavaScript(code, { filename: 'mobile-config.js', symbols: { App: createAppConfiguration(this) } }); @@ -260,7 +260,7 @@ export class CordovaBuilder { } } - writeConfigXmlAndCopyResources(shouldCopyResources = true) { + async writeConfigXmlAndCopyResources(shouldCopyResources = true) { let config = XmlBuilder.create({ version: '1.0' }).ele('widget'); // Set the root attributes @@ -341,7 +341,7 @@ export class CordovaBuilder { } if (shouldCopyResources) { // Prepare the resources folder - files.rm_recursive(this.resourcesPath); + await files.rm_recursive(this.resourcesPath); files.mkdir_p(this.resourcesPath); Console.debug('Copying resources for mobile apps'); @@ -614,14 +614,14 @@ export class CordovaBuilder { return boilerplate.toHTMLAsync(); } - copyBuildOverride() { + async copyBuildOverride() { const buildOverridePath = files.pathJoin(this.projectContext.projectDir, 'cordova-build-override'); if (files.exists(buildOverridePath) && files.stat(buildOverridePath).isDirectory()) { Console.debug('Copying over the cordova-build-override directory'); - files.cp_r(buildOverridePath, this.projectRoot); + await files.cp_r(buildOverridePath, this.projectRoot); } } } diff --git a/tools/cordova/index.js b/tools/cordova/index.js index eb5e8d0f35..f12c481200 100644 --- a/tools/cordova/index.js +++ b/tools/cordova/index.js @@ -41,8 +41,8 @@ export function ensureDevBundleDependencies() { title: 'Installing Cordova in Meteor tool', }, async () => { - await require("../cli/dev-bundle-helpers.js") - .ensureDependencies(CORDOVA_DEV_BUNDLE_VERSIONS); + await (require("../cli/dev-bundle-helpers.js") + .ensureDependencies(CORDOVA_DEV_BUNDLE_VERSIONS)); const cordovaNodeModulesDir = pathJoin( getDevBundle(), diff --git a/tools/cordova/project.js b/tools/cordova/project.js index 531bd39f69..3855d9bd67 100644 --- a/tools/cordova/project.js +++ b/tools/cordova/project.js @@ -158,7 +158,7 @@ export class CordovaProject { outdated platforms`); // Remove Cordova project directory to start afresh // and avoid a broken project - files.rm_recursive(this.projectRoot); + await files.rm_recursive(this.projectRoot); } } @@ -195,7 +195,7 @@ outdated platforms`); } // Don't copy resources (they will be copied as part of the prepare) - builder.writeConfigXmlAndCopyResources(false); + await builder.writeConfigXmlAndCopyResources(false); // Create the Cordova project root directory files.mkdir_p(files.pathDirname(this.projectRoot)); @@ -271,7 +271,7 @@ outdated platforms`); return; } - builder.writeConfigXmlAndCopyResources(); + await builder.writeConfigXmlAndCopyResources(); await builder.copyWWW(bundlePath); await this.ensurePluginsAreSynchronized(pluginVersions, @@ -291,7 +291,7 @@ outdated platforms`); 'LD_RUNPATH_SEARCH_PATHS = @executable_path/Frameworks;'); } - builder.copyBuildOverride(); + await builder.copyBuildOverride(); } async prepareForPlatform(platform, options) { @@ -348,11 +348,7 @@ ${displayNameForPlatform(platform)}`, async () => { await this.runCommands( `running Cordova app for platform \ ${displayNameForPlatform(platform)} with options ${options}`, - async () => { - await cordova_lib.run(commandOptions); - } - ); - + () => cordova_lib.run(commandOptions)); } // Platforms diff --git a/tools/cordova/run-targets.js b/tools/cordova/run-targets.js index 420eef3967..2541680280 100644 --- a/tools/cordova/run-targets.js +++ b/tools/cordova/run-targets.js @@ -32,7 +32,7 @@ export class iOSRunTarget extends CordovaRunTarget { await cordovaProject.run(this.platform, this.isDevice, undefined); // Bring iOS Simulator to front (it is called Simulator in Xcode 7) - execFileAsync('osascript', ['-e', + await execFileAsync('osascript', ['-e', `tell application "System Events" set possibleSimulatorNames to {"iOS Simulator", "Simulator"} repeat with possibleSimulatorName in possibleSimulatorNames @@ -102,7 +102,7 @@ export class AndroidRunTarget extends CordovaRunTarget { let target = this.isDevice ? "-d" : "-e"; // Clear logs - execFileAsync('adb', [target, 'logcat', '-c']); + await execFileAsync('adb', [target, 'logcat', '-c']); await cordovaProject.run(this.platform, this.isDevice); diff --git a/tools/cordova/runner.js b/tools/cordova/runner.js index 5ac5e8bfc9..e137b6010f 100644 --- a/tools/cordova/runner.js +++ b/tools/cordova/runner.js @@ -73,7 +73,6 @@ export class CordovaRunner { buildmessage.assertInCapture(); await buildmessage.enterJob({ title: "preparing Cordova project" }, async () => { - // TODO -> Cordova Setup await this.cordovaProject.prepareFromAppBundle(bundlePath, pluginVersions, options); From fb16d6abcb5e634466621051e13f7258c2aec13f Mon Sep 17 00:00:00 2001 From: matheusccastro Date: Wed, 10 May 2023 22:55:27 -0300 Subject: [PATCH 2/3] Remove `projectContext.init` since it doesn't need to be async anymore because `archinfo.host` is sync - also adding missing `awaits` to runners. --- tools/cli/commands-cordova.js | 1 - tools/cli/commands-packages-query.js | 1 - tools/cli/commands-packages.js | 13 ------------- tools/cli/commands.js | 12 +----------- tools/project-context.js | 7 ++----- tools/runners/run-app.js | 2 +- tools/runners/run-mongo.js | 4 ++-- tools/tests/old/test-bundler-assets.js | 2 -- tools/tests/old/test-bundler-options.js | 1 - tools/tests/wipe-all-packages.js | 6 +++--- 10 files changed, 9 insertions(+), 40 deletions(-) diff --git a/tools/cli/commands-cordova.js b/tools/cli/commands-cordova.js index 1b4557aecc..bdff7c274c 100644 --- a/tools/cli/commands-cordova.js +++ b/tools/cli/commands-cordova.js @@ -16,7 +16,6 @@ async function createProjectContext(appDir) { const projectContext = new ProjectContext({ projectDir: appDir }); - await projectContext.init(); await main.captureAndExit('=> Errors while initializing project:', async () => { // We're just reading metadata here; we don't need to resolve constraints. await projectContext.readProjectMetadata(); diff --git a/tools/cli/commands-packages-query.js b/tools/cli/commands-packages-query.js index 14370d6cbb..81f75f71c0 100644 --- a/tools/cli/commands-packages-query.js +++ b/tools/cli/commands-packages-query.js @@ -155,7 +155,6 @@ var getTempContext = async function (options) { explicitlyAddedLocalPackageDirs: currentPackageDir }); } - await projectContext.init(); // It is possible that we can't process package.js files in our local packages // and have to exit early. This is unfortunate, but we can't search local diff --git a/tools/cli/commands-packages.js b/tools/cli/commands-packages.js index 041d869035..9027e7c0ba 100644 --- a/tools/cli/commands-packages.js +++ b/tools/cli/commands-packages.js @@ -104,7 +104,6 @@ main.registerCommand({ neverWritePackageMap: true, allowIncompatibleUpdate: options['allow-incompatible-update'] }); - await projectContext.init(); await main.captureAndExit("=> Errors while initializing project:", async function () { await projectContext.initializeCatalog(); }); @@ -150,7 +149,6 @@ main.registerCommand({ projectDir: options.appDir, allowIncompatibleUpdate: options['allow-incompatible-update'] }); - await projectContext.init(); await main.captureAndExit("=> Errors while initializing project:", async function () { await projectContext.prepareProjectForBuild(); @@ -303,7 +301,6 @@ main.registerCommand({ lintPackageWithSourceRoot: options['no-lint'] ? null : options.packageDir, }); } - await projectContext.init(); await main.captureAndExit("=> Errors while initializing project:", async function () { // Just get up to initializing the catalog. We're going to mutate the @@ -644,7 +641,6 @@ main.registerCommand({ forceIncludeCordovaUnibuild: true, allowIncompatibleUpdate: options['allow-incompatible-update'] }); - await projectContext.init() // Just get up to initializing the catalog. We're going to mutate the // constraints file a bit before we prepare the build. await main.captureAndExit("=> Errors while initializing project:", async function () { @@ -863,7 +859,6 @@ main.registerCommand({ // though this temporary directory does not have any cordova platforms forceIncludeCordovaUnibuild: true }); - await projectContext.init(); // Read metadata and initialize catalog. await main.captureAndExit("=> Errors while building for release:", async function () { await projectContext.initializeCatalog(); @@ -1178,7 +1173,6 @@ main.registerCommand({ projectDir: options.appDir, allowIncompatibleUpdate: options['allow-incompatible-update'] }); - await projectContext.init(); await main.captureAndExit("=> Errors while initializing project:", async function () { return await projectContext.prepareProjectForBuild(); @@ -1627,7 +1621,6 @@ var maybeUpdateRelease = async function (options) { alwaysWritePackageMap: true, allowIncompatibleUpdate: true // disregard `.meteor/versions` if necessary }); - await projectContext.init() await main.captureAndExit("=> Errors while initializing project:", async function () { await projectContext.readProjectMetadata(); }); @@ -1837,7 +1830,6 @@ main.registerCommand({ alwaysWritePackageMap: true, allowIncompatibleUpdate: options["allow-incompatible-update"] }); - await projectContext.init() await main.captureAndExit("=> Errors while initializing project:", async function () { await projectContext.readProjectMetadata(); }); @@ -2053,7 +2045,6 @@ main.registerCommand({ projectDir: options.appDir, allowIncompatibleUpdate: options['allow-incompatible-update'] }); - await projectContext.init() await main.captureAndExit("=> Errors while initializing project:", async function () { await projectContext.prepareProjectForBuild(); }); @@ -2122,7 +2113,6 @@ main.registerCommand({ // though this temporary directory does not have any cordova platforms forceIncludeCordovaUnibuild: true }); - await projectContext.init() // Read metadata and initialize catalog. await main.captureAndExit("=> Errors while building for release:", async function () { await projectContext.initializeCatalog(); @@ -2162,8 +2152,6 @@ main.registerCommand({ allowIncompatibleUpdate: options["allow-incompatible-update"] }); - await projectContext.init(); - await main.captureAndExit("=> Errors while initializing project:", async function () { // We're just reading metadata here --- we're not going to resolve // constraints until after we've made our changes. @@ -2371,7 +2359,6 @@ main.registerCommand({ projectDir: options.appDir, allowIncompatibleUpdate: options["allow-incompatible-update"] }); - await projectContext.init(); await main.captureAndExit("=> Errors while initializing project:", async function () { // We're just reading metadata here --- we're not going to resolve diff --git a/tools/cli/commands.js b/tools/cli/commands.js index d0cd3c1f39..9bdaaf6994 100644 --- a/tools/cli/commands.js +++ b/tools/cli/commands.js @@ -362,7 +362,6 @@ async function doRunCommand(options) { lintAppAndLocalPackages: !options['no-lint'], includePackages: includePackages, }); - await projectContext.init(); await main.captureAndExit("=> Errors while initializing project:", function () { // We're just reading metadata here --- we'll wait to do the full build @@ -500,7 +499,6 @@ main.registerCommand({ var projectContext = new projectContextModule.ProjectContext({ projectDir: options.appDir }); - await projectContext.init(); // Convert to OS path here because shell/server.js doesn't know how to // convert paths, since it exists in the app and in the tool. @@ -847,8 +845,6 @@ main.registerCommand({ allowIncompatibleUpdate: true }); - await projectContext.init(); - await main.captureAndExit("=> Errors while creating your project", async function () { await projectContext.readProjectMetadata(); if (buildmessage.jobHasMessages()) { @@ -1049,7 +1045,6 @@ var buildCommand = async function (options) { serverArchitectures: _.uniq([bundleArch, archinfo.host()]), allowIncompatibleUpdate: options['allow-incompatible-update'] }); - await projectContext.init(); await main.captureAndExit("=> Errors while initializing project:", function () { // TODO Fix the nested Profile.run warning here, without interfering @@ -1327,7 +1322,6 @@ main.registerCommand({ allowIncompatibleUpdate: options['allow-incompatible-update'], lintPackageWithSourceRoot: packageDir }); - await projectContext.init() await main.captureAndExit("=> Errors while setting up package:", // Read metadata and initialize catalog. @@ -1353,7 +1347,6 @@ main.registerCommand({ allowIncompatibleUpdate: options['allow-incompatible-update'], lintAppAndLocalPackages: true }); - await projectContext.init() } @@ -1623,7 +1616,6 @@ async function deployCommand(options, { rawOptions }) { serverArchitectures: _.uniq([buildArch, archinfo.host()]), allowIncompatibleUpdate: options['allow-incompatible-update'] }); - await projectContext.init() await main.captureAndExit("=> Errors while initializing project:", function () { // TODO Fix nested Profile.run warning here, too. return projectContext.prepareProjectForBuild(); @@ -1948,7 +1940,6 @@ async function doTestCommand(options) { // repeated test-packages calls with some sort of shared or semi-shared // isopack cache that's specific to test-packages? See #3012. projectContext = new projectContextModule.ProjectContext(projectContextOptions); - await projectContext.init(); await main.captureAndExit("=> Errors while initializing project:", function () { // We're just reading metadata here --- we'll wait to do the full build @@ -2041,7 +2032,6 @@ async function doTestCommand(options) { await copyDirIntoTestRunnerApp(true, '.meteor', 'local', 'shell'); projectContext = new projectContextModule.ProjectContext(projectContextOptions); - await projectContext.init(); await main.captureAndExit("=> Errors while setting up tests:", async function () { // Read metadata and initialize catalog. @@ -2826,7 +2816,7 @@ main.registerCommand({ throw new main.ExitWithCode(2); } - files.cp_r(assetsPath(), files.pathResolve(scaffoldPath), { + await files.cp_r(assetsPath(), files.pathResolve(scaffoldPath), { transformFilename: function (f) { if (options.replaceFn) return userTransformFilenameFn(f); return transformName(f); diff --git a/tools/project-context.js b/tools/project-context.js index d6746f2823..1fb15c48f8 100644 --- a/tools/project-context.js +++ b/tools/project-context.js @@ -124,6 +124,7 @@ function ProjectContext(options) { throw Error("missing projectDir!"); self.originalOptions = options; + self.reset(); } exports.ProjectContext = ProjectContext; @@ -139,11 +140,7 @@ var STAGE = { }; Object.assign(ProjectContext.prototype, { - init: function () { - const self = this; - return self.reset(); - }, - reset: async function (moreOptions, resetOptions) { + reset: function (moreOptions, resetOptions) { var self = this; // Allow overriding some options until the next call to reset; var options = Object.assign({}, self.originalOptions, moreOptions); diff --git a/tools/runners/run-app.js b/tools/runners/run-app.js index 6caf810d0b..5c517874f0 100644 --- a/tools/runners/run-app.js +++ b/tools/runners/run-app.js @@ -970,7 +970,7 @@ Object.assign(AppRunner.prototype, { }); firstRun = false; - var wantExit = self.onRunEnd ? !self.onRunEnd(runResult) : false; + var wantExit = self.onRunEnd ? !(await self.onRunEnd(runResult)) : false; if (wantExit || self.exitPromise || runResult.outcome === "stopped") { break; } diff --git a/tools/runners/run-mongo.js b/tools/runners/run-mongo.js index fb06df047c..cac9542d27 100644 --- a/tools/runners/run-mongo.js +++ b/tools/runners/run-mongo.js @@ -543,7 +543,7 @@ var launchMongo = async function(options) { require('../tool-env/cleanup.js').onExit(stop); subHandles.push({ stop }); - var procExitHandler = await fiberHelpers.bindEnvironment(async function(code, signal) { + var procExitHandler = fiberHelpers.bindEnvironment(async function(code, signal) { // Defang subHandle.stop(). proc = null; @@ -973,7 +973,7 @@ Object.assign(MRp, { if (self.errorCount < 3) { // Wait a second, then restart. - self.restartTimer = await setTimeout( + self.restartTimer = setTimeout( fiberHelpers.bindEnvironment(async function() { self.restartTimer = null; await self._startOrRestart(); diff --git a/tools/tests/old/test-bundler-assets.js b/tools/tests/old/test-bundler-assets.js index 059faf9f68..c0c1278434 100644 --- a/tools/tests/old/test-bundler-assets.js +++ b/tools/tests/old/test-bundler-assets.js @@ -33,8 +33,6 @@ var makeProjectContext = async function (appName) { projectDir: projectDir }); - await projectContext.init(); - await doOrThrow(async function () { await projectContext.prepareProjectForBuild(); }); diff --git a/tools/tests/old/test-bundler-options.js b/tools/tests/old/test-bundler-options.js index 538fa9a61b..2bf8d00aa1 100644 --- a/tools/tests/old/test-bundler-options.js +++ b/tools/tests/old/test-bundler-options.js @@ -27,7 +27,6 @@ var makeProjectContext = async function (appName) { var projectContext = new projectContextModule.ProjectContext({ projectDir: projectDir }); - await projectContext.init(); await doOrThrow(async function () { await projectContext.prepareProjectForBuild(); }); diff --git a/tools/tests/wipe-all-packages.js b/tools/tests/wipe-all-packages.js index 3cfc16936e..016c3aa52a 100644 --- a/tools/tests/wipe-all-packages.js +++ b/tools/tests/wipe-all-packages.js @@ -35,9 +35,9 @@ selftest.define("wipe all packages", ['slow', 'custom-warehouse'], async functio containsPlugins: false }; }; - var meteorToolBuild = async function (v) { + var meteorToolBuild = function (v) { return { - buildArchitectures: await archinfo.host(), + buildArchitectures: archinfo.host(), versionId: 'VID' + v.replace(/\./g, ''), _id: utils.randomToken() }; @@ -50,7 +50,7 @@ selftest.define("wipe all packages", ['slow', 'custom-warehouse'], async functio collections: { packages: [], versions: [meteorToolVersion('33.0.1'), meteorToolVersion('33.0.2'), meteorToolVersion('33.0.3')], - builds: [await meteorToolBuild('33.0.1'), await meteorToolBuild('33.0.2'), await meteorToolBuild('33.0.3')], + builds: [meteorToolBuild('33.0.1'), meteorToolBuild('33.0.2'), meteorToolBuild('33.0.3')], releaseTracks: [], releaseVersions: [] } From 6922fb6457d339d7b4fc76c73d10df3ed54c1871 Mon Sep 17 00:00:00 2001 From: matheusccastro Date: Mon, 15 May 2023 18:32:14 -0300 Subject: [PATCH 3/3] Remove unneeded awaits and run `_runApp` in a clean context. --- tools/runners/run-all.js | 12 +++--------- tools/runners/run-app.js | 38 ++++++++++++++------------------------ tools/runners/run-mongo.js | 4 ++-- tools/runners/run-proxy.js | 4 ++-- 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/tools/runners/run-all.js b/tools/runners/run-all.js index 0e9b37b987..4dfc6bfce2 100644 --- a/tools/runners/run-all.js +++ b/tools/runners/run-all.js @@ -170,10 +170,6 @@ class Runner { runLog.log("Started proxy.", { arrow: true }); } - /** - * - * @type {(function(): *)} - */ var unblockAppRunner = self.appRunner.makeBeforeStartPromise(); function startMongo(tries = 3) { @@ -185,7 +181,7 @@ class Runner { const left = tries + (tries === 1 ? " try" : " tries"); Console.log(`Error starting Mongo (${left} left): ${error.message}`); if (tries > 0) { - await self.mongoRunner.stop(); + self.mongoRunner.stop(); setTimeout(() => startMongo(tries), 1000); } else { await self.mongoRunner._fail(); @@ -208,9 +204,7 @@ class Runner { } if (! self.stopped) { - await buildmessage.enterJob({ title: "starting your app" }, async function () { - await self.appRunner.start(); - }); + await buildmessage.enterJob({ title: "starting your app" }, () => self.appRunner.start()); if (! self.quiet && ! self.stopped) { runLog.log("Started your app.", { arrow: true }); } @@ -402,7 +396,7 @@ exports.run = async function (options) { var runner = new Runner(runOptions); await runner.init(); // don't wait this on to finish - runner.start(); + setTimeout(() => runner.start(), 0); var result = await promise; await runner.stop(); diff --git a/tools/runners/run-app.js b/tools/runners/run-app.js index 5c517874f0..d00ab78308 100644 --- a/tools/runners/run-app.js +++ b/tools/runners/run-app.js @@ -104,7 +104,7 @@ Object.assign(AppProcess.prototype, { // Watch for exit and for stdio to be fully closed (so that we don't miss // log lines). self.proc.on('close', async function (code, signal) { - self._maybeCallOnExit(code, signal); + await self._maybeCallOnExit(code, signal); }); self.proc.on('error', async function (err) { @@ -113,7 +113,7 @@ Object.assign(AppProcess.prototype, { // node docs say that it might make both an 'error' and a // 'close' callback, so we use a guard to make sure we only call // onExit once. - self._maybeCallOnExit(); + await self._maybeCallOnExit(); }); // This happens sometimes when we write a keepalive after the app @@ -123,13 +123,13 @@ Object.assign(AppProcess.prototype, { self.proc.stdin.on('error', function () {}); }, - _maybeCallOnExit: function (code, signal) { + _maybeCallOnExit: async function (code, signal) { var self = this; if (self.madeExitCallback) { return; } self.madeExitCallback = true; - self.onExit && self.onExit(code, signal); + self.onExit && await self.onExit(code, signal); }, // Idempotent. Once stop() returns it is guaranteed that you will @@ -404,7 +404,9 @@ Object.assign(AppRunner.prototype, { self.startPromise = self._makePromise("start"); self.isRunning = true; - self._runApp().catch((e) => self._resolvePromise("start", e)); + global.asyncLocalStorage.run({}, () => + self._runApp().catch((e) => self._resolvePromise("start", e)) + ); await self.startPromise; self.startPromise = null; }, @@ -416,12 +418,6 @@ Object.assign(AppRunner.prototype, { return this._promiseResolvers[name]; }, - _makeIterable : function (name) { - var self = this; - const ee = self._findCachedEE(name); - return on(ee, name); - }, - /** * @param name * @return {Promise<[any]>} @@ -527,7 +523,7 @@ Object.assign(AppRunner.prototype, { // to how the WatchSets are laid out. Might be possible to avoid // re-building the local catalog at all if packages didn't change // at all, though.) - await self.projectContext.reset({}, { + self.projectContext.reset({}, { // Don't forget all Isopack objects; just make sure to check that they // are up to date. softRefreshIsopacks: true, @@ -539,9 +535,7 @@ Object.assign(AppRunner.prototype, { // shown from the previous solution. preservePackageMap: true }); - var messages = await buildmessage.capture(async function () { - return await self.projectContext.readProjectMetadata(); - }); + var messages = await buildmessage.capture(() => self.projectContext.readProjectMetadata()); if (messages.hasMessages()) { return { runResult: { @@ -565,9 +559,7 @@ Object.assign(AppRunner.prototype, { }; } - messages = await buildmessage.capture(async function () { - return await self.projectContext.prepareProjectForBuild(); - }); + messages = await buildmessage.capture(() => self.projectContext.prepareProjectForBuild()); if (messages.hasMessages()) { return { runResult: { @@ -591,8 +583,8 @@ Object.assign(AppRunner.prototype, { }); } - var bundleResult = await Profile.run((firstRun?"B":"Reb")+"uild App", async function() { - return await bundler.bundle({ + var bundleResult = await Profile.run((firstRun?"B":"Reb")+"uild App", async () => + bundler.bundle({ projectContext: self.projectContext, outputPath: bundlePath, includeNodeModules: "symlink", @@ -607,8 +599,7 @@ Object.assign(AppRunner.prototype, { // None of the targets are used during full rebuilds // so we can safely build in place on Windows forceInPlaceBuild: !cachedServerWatchSet - }); - }); + })); // Keep the server watch set from the initial bundle, because subsequent // bundles will not contain a server target. @@ -685,7 +676,6 @@ Object.assign(AppRunner.prototype, { if (!cordovaRunner.started) { const { settingsFile, mobileServerUrl } = self; const messages = await buildmessage.capture(async () => { - // TODO -> Check cordova await cordovaRunner.prepareProject(bundlePath, pluginVersions, { settingsFile, mobileServerUrl }); }); @@ -728,7 +718,7 @@ Object.assign(AppRunner.prototype, { var listenPromise = self._makePromise("listen"); // Run the program - options.beforeRun && options.beforeRun(); + options.beforeRun && await options.beforeRun(); var appProcess = new AppProcess({ projectContext: self.projectContext, bundlePath: bundlePath, diff --git a/tools/runners/run-mongo.js b/tools/runners/run-mongo.js index cac9542d27..d284dfcd7a 100644 --- a/tools/runners/run-mongo.js +++ b/tools/runners/run-mongo.js @@ -1061,10 +1061,10 @@ Object.assign(MRp, { } }, - _fail: function() { + _fail: async function() { var self = this; self.stop(); - self.onFailure && self.onFailure(); + self.onFailure && await self.onFailure(); self._allowStartupToReturn(); }, diff --git a/tools/runners/run-proxy.js b/tools/runners/run-proxy.js index 62b8c53849..f237f68fde 100644 --- a/tools/runners/run-proxy.js +++ b/tools/runners/run-proxy.js @@ -71,7 +71,7 @@ Object.assign(Proxy.prototype, { allowStart = resolve; }); - self.server.on('error', function (err) { + self.server.on('error', async function (err) { if (err.code === 'EADDRINUSE') { var port = self.listenPort; runLog.log( @@ -92,7 +92,7 @@ Object.assign(Proxy.prototype, { } else { runLog.log('' + err); } - self.onFailure(); + await self.onFailure(); allowStart(); });