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 5A6641880D for ; Wed, 2 Mar 2016 23:59:53 +0000 (UTC) Received: (qmail 9946 invoked by uid 500); 2 Mar 2016 23:59:52 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 9906 invoked by uid 500); 2 Mar 2016 23:59:52 -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 9895 invoked by uid 99); 2 Mar 2016 23:59:52 -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; Wed, 02 Mar 2016 23:59:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8C1FDDFFF8; Wed, 2 Mar 2016 23:59:52 +0000 (UTC) From: riknoll 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: <20160302235952.8C1FDDFFF8@git1-us-west.apache.org> Date: Wed, 2 Mar 2016 23:59:52 +0000 (UTC) Github user riknoll commented on a diff in the pull request: https://github.com/apache/cordova-lib/pull/363#discussion_r54814983 --- 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 -- Right! I wrote this before I was aware that jasmine could mock function calls. As you said, I want to get this in today so I'm going to leave it out for now since that would be a big change to the tests.. --- 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