Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 03B011853C for ; Thu, 18 Feb 2016 10:54:04 +0000 (UTC) Received: (qmail 96813 invoked by uid 500); 18 Feb 2016 10:54:00 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 96769 invoked by uid 500); 18 Feb 2016 10:54:00 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 96758 invoked by uid 99); 18 Feb 2016 10:54:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Feb 2016 10:54:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 07A45DFF67; Thu, 18 Feb 2016 10:54:00 +0000 (UTC) From: TimBarham To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-lib pull request: New plugin version selection implementat... Content-Type: text/plain Message-Id: <20160218105400.07A45DFF67@git1-us-west.apache.org> Date: Thu, 18 Feb 2016 10:54:00 +0000 (UTC) Github user TimBarham commented on a diff in the pull request: https://github.com/apache/cordova-lib/pull/363#discussion_r53298645 --- Diff: cordova-lib/src/cordova/util.js --- @@ -185,6 +187,31 @@ function listPlatforms(project_dir) { }); } +function getInstalledPlatformsWithVersions(project_dir) { + var platforms_on_fs = listPlatforms(project_dir); + + return Q.all(platforms_on_fs.map(function(p) { + return superspawn.maybeSpawn(path.join(project_dir, 'platforms', p, 'cordova', 'version'), [], { chmod: true }) + .then(function(v) { + return { + platform: p, + version: v ? v : null + }; + }, function(v) { + return { + platform: p, + version: 'broken' + }; + }); + })).then(function(platformVersions) { + var result = {}; + for(var i = 0; i < platformVersions.length; i++) { + result[platformVersions[i].platform] = platformVersions[i].version; + } + return result; + }); +} --- End diff -- The above method would be simplified if you just accumulated the `result` object as you go... As in... initialize `result` before the `Q.all()` call, then instead of, for example, `return { platform: p, version: v ? v : null };` you would just do `result[p] = v || null;`. In the final then, you would ignore the parameter and just return `result`. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org For additional commands, e-mail: dev-help@cordova.apache.org