cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cordova-lib git commit: CB-9559 Adding a plugin with caret in version results in an error
Date Fri, 28 Aug 2015 04:20:52 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master fc348595b -> 536893763


CB-9559 Adding a plugin with caret in version results in an error

When Cordova used npm 1.3.x internally, we had to process "caret versions" since npm 1.3.x
didn't understand them. As part of that, we'd turn the caret version into a fully defined
version range, which contained a space, and npm 1.3.x required that we wrap such a range in
quotes.

This logic broke when we upgraded to npm 2.10.x - it no longer requires the quotes in this
scenario, and in fact fails if we include them. However, we also no longer need to do this
processing (since npm 2.10.x understands caret versions), so we can just remove that code
altogether.


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/53689376
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/53689376
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/53689376

Branch: refs/heads/master
Commit: 536893763569837013a7d89d75eb31642e18af83
Parents: fc34859
Author: Tim Barham <tim.barham@microsoft.com>
Authored: Fri Aug 28 13:39:19 2015 +1000
Committer: Tim Barham <tim.barham@microsoft.com>
Committed: Fri Aug 28 14:16:04 2015 +1000

----------------------------------------------------------------------
 cordova-lib/src/plugman/registry/registry.js | 25 ++---------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/53689376/cordova-lib/src/plugman/registry/registry.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/registry/registry.js b/cordova-lib/src/plugman/registry/registry.js
index 52d3954..0965bd4 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -19,8 +19,7 @@
 
 /* jshint laxcomma:true */
 
-var semver = require('semver'),
-    npm = require('npm'),
+var npm = require('npm'),
     path = require('path'),
     url = require('url'),
     fs = require('fs'),
@@ -267,7 +266,7 @@ function fetchPlugin(plugin, client, useNpmRegistry) {
 
     return initThenLoadSettingsWithRestore(useNpmRegistry, function () {
         events.emit('log', 'Fetching plugin "' + plugin + '" via ' + registryName);
-        return Q.ninvoke(npm.commands, 'cache', ['add', processPluginVersion(plugin)])
+        return Q.ninvoke(npm.commands, 'cache', ['add', plugin])
         .then(function (info) {
             var cl = (client === 'plugman' ? 'plugman' : 'cordova-cli');
             bumpCounter(info, cl);
@@ -279,26 +278,6 @@ function fetchPlugin(plugin, client, useNpmRegistry) {
     });
 }
 
-function processPluginVersion(plugin) {
-    // If plugin includes a version that is a caret range, the ancient version of npm we're
using won't know how to
-    // handle it. So we'll use our current version of semver to turn it into a usable range.
-
-    var parts = plugin.split('@');
-    var version = parts[1];
-
-    if (!version || version.charAt(0) !== '^') {
-        return plugin;
-    }
-
-    var validRange = semver.validRange(version, /* loose */ true);
-    if (!validRange) {
-        return plugin;
-    }
-
-    // Because validRange may include spaces, we need to wrap it in quotes.
-    return parts[0] + '@"' + validRange + '"';
-}
-
 /**
  * @param {Array} with one element - the plugin id or "id@version"
  * @return {Boolean} if plugin id is reverse domain name style.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message