cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From TimBarham <...@git.apache.org>
Subject [GitHub] cordova-lib pull request: New plugin version selection implementat...
Date Thu, 18 Feb 2016 10:54:00 GMT
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


Mime
View raw message