You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2020/11/20 11:24:44 UTC
[cordova-paramedic] 05/12: fix: lib issues
This is an automated email from the ASF dual-hosted git repository.
timbru31 pushed a commit to branch feat/gh-actions
in repository https://gitbox.apache.org/repos/asf/cordova-paramedic.git
commit 49be462e6f7c8387cdfbde056887fc044dfe5700
Author: Tim Brust <ti...@sinnerschrader.com>
AuthorDate: Thu Sep 3 12:55:51 2020 +0200
fix: lib issues
---
lib/ParamedicTargetChooser.js | 4 ++--
lib/paramedic.js | 2 +-
lib/utils/utilities.js | 11 ++++++++---
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/lib/ParamedicTargetChooser.js b/lib/ParamedicTargetChooser.js
index 8b4665b..6816c5c 100644
--- a/lib/ParamedicTargetChooser.js
+++ b/lib/ParamedicTargetChooser.js
@@ -32,7 +32,7 @@ class ParamedicTargetChooser {
}
chooseTarget (emulator, target) {
- let targetObj = '';
+ let targetObj = Q();
switch (this.platform) {
case utilities.ANDROID:
@@ -59,7 +59,7 @@ class ParamedicTargetChooser {
if (target) {
logger.info('cordova-paramedic: Target defined as: ' + target);
- return { target };
+ return Q({ target });
}
return this.startAnAndroidEmulator(target).then(emulatorId => ({ target: emulatorId }));
diff --git a/lib/paramedic.js b/lib/paramedic.js
index 677ccbb..1ca768d 100644
--- a/lib/paramedic.js
+++ b/lib/paramedic.js
@@ -424,7 +424,7 @@ class ParamedicRunner {
}
// For now we always trying to run test app on emulator
- return (new ParamedicTargetChooser(this.tempFolder.name, this.config)).chooseTarget(
+ return new ParamedicTargetChooser(this.tempFolder.name, this.config).chooseTarget(
true, // useEmulator
this.config.getTarget() // preferredTarget
).then(targetObj => {
diff --git a/lib/utils/utilities.js b/lib/utils/utilities.js
index 72f63cd..1f94a1d 100644
--- a/lib/utils/utilities.js
+++ b/lib/utils/utilities.js
@@ -88,9 +88,14 @@ function getSimulatorModelId (cli, target) {
logger.info(`Filtering for Targeted Emulator: ${target}`);
// Return the individual target that is filtered from the known simulators/emulators based on provided target name. (default: ^iPhone)
- return result.stdout
- .split('\n')
- .filter(i => i.match(target))
+ const allSimulators = result.stdout
+ .split('\n');
+ const matchingSimulators = allSimulators.filter(i => i.match(target));
+ if (!matchingSimulators.length) {
+ logger.warn('Unable to find requested simulator, falling back to the first available!');
+ return allSimulators.filter(i => i.match(/^iPhone/)).pop().trim();
+ }
+ return matchingSimulators
.pop()
.trim();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org