This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-lib.git
The following commit(s) were added to refs/heads/master by this push:
new a33d6a28 feat!(run): call platform api to list targets (#917)
a33d6a28 is described below
commit a33d6a2891478bf18bf44fb35d321474efaeb6eb
Author: エリス <[email protected]>
AuthorDate: Mon May 8 14:47:54 2023 +0900
feat!(run): call platform api to list targets (#917)
* feat!(run): call platform api to list targets
* fix: require platform for cordova run --list flag
* revert: cleanup diff log
* fix: set options defaults and safe variable usage
* chore: enabled warning to upgrade platform for uninterrupted fetching of
target lists
---
src/cordova/run.js | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/cordova/run.js b/src/cordova/run.js
index b66b4713..52fcc947 100644
--- a/src/cordova/run.js
+++ b/src/cordova/run.js
@@ -18,12 +18,40 @@
*/
const cordova_util = require('./util');
+const { events } = require('cordova-common');
const HooksRunner = require('../hooks/HooksRunner');
const platform_lib = require('../platforms/platforms');
const cordovaPrepare = require('./prepare');
+// Support for listing targets.
+const targets = require('./targets');
+
// Returns a promise.
-module.exports = function run (options) {
+module.exports = function run (options = {}) {
+ const { options: cliArgs } = options;
+
+ if (cliArgs?.list) {
+ const { platforms } = options;
+
+ if (platforms.length <= 0) {
+ events.emit('warn', 'A platform must be provided when using the
"--list" flag.');
+ return false;
+ }
+
+ return Promise.resolve(platforms.map(function (platform) {
+ const platformApi = platform_lib.getPlatformApi(platform);
+
+ if (platformApi?.listTargets) {
+ // Use Platform's API to fetch target list when available
+ return platformApi.listTargets(options);
+ } else {
+ events.emit('warn', 'Please update to the latest platform
release to ensure uninterrupted fetching of target lists.');
+ // fallback to original method.
+ return targets(options);
+ }
+ }));
+ }
+
return Promise.resolve().then(function () {
const projectRoot = cordova_util.cdProjectRoot();
options = cordova_util.preProcessOptions(options);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]