You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by dp...@apache.org on 2024/10/08 08:27:47 UTC

(cordova-ios) branch master updated: fix(emulators): Fix listing emulator targets (#1495)

This is an automated email from the ASF dual-hosted git repository.

dpogue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-ios.git


The following commit(s) were added to refs/heads/master by this push:
     new ff69ddd1 fix(emulators): Fix listing emulator targets (#1495)
ff69ddd1 is described below

commit ff69ddd1e6aa33888cbf5ce3c2625d0d9827b523
Author: Darryl Pogue <da...@dpogue.ca>
AuthorDate: Tue Oct 8 01:27:42 2024 -0700

    fix(emulators): Fix listing emulator targets (#1495)
---
 lib/listEmulatorBuildTargets.js |  2 --
 lib/run.js                      | 10 +++++-----
 tests/spec/unit/run.spec.js     | 12 ++++++------
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/lib/listEmulatorBuildTargets.js b/lib/listEmulatorBuildTargets.js
index c3d7b8b4..0377c9e7 100644
--- a/lib/listEmulatorBuildTargets.js
+++ b/lib/listEmulatorBuildTargets.js
@@ -18,7 +18,6 @@
 */
 
 const execa = require('execa');
-const { events } = require('cordova-common');
 
 /**
  * Returns a list of available simulator build targets of the form
@@ -32,7 +31,6 @@ const { events } = require('cordova-common');
  *
  */
 function listEmulatorBuildTargets () {
-    events.emit('log', 'List simulator targets');
     return execa('xcrun', ['simctl', 'list', '--json'])
         .then(({ stdout }) => JSON.parse(stdout))
         .then(function (simInfo) {
diff --git a/lib/run.js b/lib/run.js
index eb35c6b0..869bd72f 100644
--- a/lib/run.js
+++ b/lib/run.js
@@ -138,7 +138,7 @@ module.exports.startSim = startSim;
 module.exports.listDevices = listDevices;
 module.exports.listEmulators = listEmulators;
 module.exports.execListDevices = execListDevices;
-module.exports.execListEmulatorTargets = execListEmulatorTargets;
+module.exports.execListEmulatorImages = execListEmulatorImages;
 
 /**
  * Filters the args array and removes supported args for the 'run' command.
@@ -207,7 +207,7 @@ async function deployToSim (appPath, target) {
 
     if (!target) {
         // Select target device for emulator (preferring iPhone Emulators)
-        const emulators = await module.exports.execListEmulatorTargets();
+        const emulators = await module.exports.execListEmulatorImages();
         const iPhoneEmus = emulators.filter(emulator => emulator.startsWith('iPhone'));
         target = iPhoneEmus.concat(emulators)[0];
         events.emit('log', `No target specified for emulator. Deploying to "${target}" simulator.`);
@@ -248,8 +248,8 @@ function execListDevices () {
 }
 
 /* istanbul ignore next */
-function execListEmulatorTargets () {
-    return require('./listEmulatorTargets').run();
+function execListEmulatorImages () {
+    return require('./listEmulatorImages').run();
 }
 
 function listDevices () {
@@ -263,7 +263,7 @@ function listDevices () {
 }
 
 function listEmulators () {
-    return module.exports.execListEmulatorTargets()
+    return module.exports.execListEmulatorImages()
         .then(emulators => {
             events.emit('log', 'Available iOS Simulators:');
             emulators.forEach(emulator => {
diff --git a/tests/spec/unit/run.spec.js b/tests/spec/unit/run.spec.js
index 8b693103..cc965abb 100644
--- a/tests/spec/unit/run.spec.js
+++ b/tests/spec/unit/run.spec.js
@@ -35,22 +35,22 @@ describe('cordova/lib/run', () => {
         beforeEach(() => {
             spyOn(events, 'emit');
             spyOn(run, 'execListDevices').and.returnValue(Promise.resolve(['iPhone Xs']));
-            spyOn(run, 'execListEmulatorTargets').and.returnValue(Promise.resolve(['iPhone 15 Simulator']));
+            spyOn(run, 'execListEmulatorImages').and.returnValue(Promise.resolve(['iPhone 15 Simulator']));
         });
 
         it('should delegate to "listDevices" when the "runListDevices" method options param contains "options.device".', () => {
             return run.runListDevices({ options: { device: true } }).then(() => {
                 expect(run.execListDevices).toHaveBeenCalled();
-                expect(run.execListEmulatorTargets).not.toHaveBeenCalled();
+                expect(run.execListEmulatorImages).not.toHaveBeenCalled();
 
                 expect(events.emit).toHaveBeenCalledWith('log', '\tiPhone Xs');
             });
         });
 
-        it('should delegate to "listDevices" when the "runListDevices" method options param contains "options.emulator".', () => {
+        it('should delegate to "listEmulators" when the "runListDevices" method options param contains "options.emulator".', () => {
             return run.runListDevices({ options: { emulator: true } }).then(() => {
                 expect(run.execListDevices).not.toHaveBeenCalled();
-                expect(run.execListEmulatorTargets).toHaveBeenCalled();
+                expect(run.execListEmulatorImages).toHaveBeenCalled();
 
                 expect(events.emit).toHaveBeenCalledWith('log', '\tiPhone 15 Simulator');
             });
@@ -59,7 +59,7 @@ describe('cordova/lib/run', () => {
         it('should delegate to both "listEmulators" and "listDevices" when the "runListDevices" method does not contain "options.device" or "options.emulator".', () => {
             return run.runListDevices().then(() => {
                 expect(run.execListDevices).toHaveBeenCalled();
-                expect(run.execListEmulatorTargets).toHaveBeenCalled();
+                expect(run.execListEmulatorImages).toHaveBeenCalled();
 
                 expect(events.emit).toHaveBeenCalledWith('log', '\tiPhone Xs');
                 expect(events.emit).toHaveBeenCalledWith('log', '\tiPhone 15 Simulator');
@@ -80,7 +80,7 @@ describe('cordova/lib/run', () => {
             spyOn(build, 'run').and.returnValue(Promise.resolve());
             spyOn(projectFile, 'parse').and.returnValue(fakeXcodeProject);
             spyOn(run, 'execListDevices').and.resolveTo([]);
-            spyOn(run, 'execListEmulatorTargets').and.resolveTo([]);
+            spyOn(run, 'execListEmulatorImages').and.resolveTo([]);
             spyOn(run, 'listDevices').and.resolveTo();
             spyOn(run, 'deployToMac').and.resolveTo();
             spyOn(run, 'deployToSim').and.resolveTo();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org