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 Wed, 02 Mar 2016 13:45:30 GMT
Github user TimBarham commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/363#discussion_r54723579
  
    --- Diff: cordova-lib/src/cordova/plugin.js ---
    @@ -305,6 +289,49 @@ module.exports = function plugin(command, targets, opts) {
         });
     };
     
    +function determinePluginTarget(projectRoot, cfg, target, fetchOptions) {
    +    var parts = target.split('@');
    +    var id = parts[0];
    +    var version = parts[1];
    +
    +    // If no version is specified, retrieve the version (or source) from config.xml
    +    if (version || cordova_util.isUrl(id) || cordova_util.isDirectory(id)) {
    +        return Q(target);
    +    } else {
    +        events.emit('verbose', 'No version specified, retrieving version from config.xml');
    +        var ver = getVersionFromConfigFile(id, cfg);
    +
    +        if (cordova_util.isUrl(ver) || cordova_util.isDirectory(ver)) {
    +            return Q(ver);
    +        } else if (ver) {
    +            // If version exists in config.xml, use that
    +            return Q(id + '@' + ver);
    +        } else {
    +            // If no version is given at all and we are fetching from npm, we
    +            // can attempt to use the Cordova dependencies the plugin lists in
    +            // their package.json
    +            var shouldUseNpmInfo = !fetchOptions.searchpath && !fetchOptions.noregistry;
    +
    +            if(shouldUseNpmInfo) {
    +                events.emit('verbose', 'No version given in config.xml, attempting to
use plugin engine info');
    +            }
    +
    +            return (shouldUseNpmInfo ? registry.info([id]) : Q({}))
    --- End diff --
    
    This feels a little hokey to me. Perhaps it would be cleaner to pass the plugin `id` and
`shouldUseNpmInfo` to `getFetchVersion()`, and let it call `registry.info()` if appropriate.
Of course, then you'd have to mock `registry` to test this. So maybe not worth the extra effort
since we want to get this change in :smile:. I'll leave it up to you.


---
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