You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2015/03/05 01:37:35 UTC
[6/8] cordova-lib git commit: CB-8551 merged fetchNPM and
fetchPlugReg into fetchPlugin
CB-8551 merged fetchNPM and fetchPlugReg into fetchPlugin
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/862c2a6f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/862c2a6f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/862c2a6f
Branch: refs/heads/CB-8551
Commit: 862c2a6fe8d864c2efa3402f017b9a3f037e4b70
Parents: 58e3dfe
Author: Steve Gill <st...@gmail.com>
Authored: Wed Mar 4 14:35:19 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Wed Mar 4 14:35:19 2015 -0800
----------------------------------------------------------------------
cordova-lib/src/plugman/registry/registry.js | 62 +++++++----------------
1 file changed, 17 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/862c2a6f/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 75549f0..7c5a7ba 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -178,11 +178,11 @@ module.exports = {
}
})
.then(function() {
- return fetchPlugReg(plugin, client);
+ return fetchPlugin(plugin, client, false);
})
.fail(function() {
module.exports.settings = null;
- return fetchNPM(plugin,client);
+ return fetchPlugin(plugin, client, true);
});
},
@@ -213,7 +213,6 @@ module.exports = {
};
/**
- * @method initSettings
* @param {Boolean} determines if we are using the npm registry
* @return {Promise.<Object>} Promised settings.
*/
@@ -339,46 +338,19 @@ function makeRequest (method, where, what, cb_) {
}
/**
- * @method fetchNPM
- * @param {Array} with one element - the plugin id or "id@version"
- * @return {Promise.<string>} Promised path to fetched package.
- */
-function fetchNPM(plugin, client) {
- return initSettings(true)
- .then(function (settings) {
- return Q.nfcall(npm.load)
- // configure npm here instead of passing parameters to npm.load due to CB-7670
- .then(function () {
- for (var prop in settings){
- npm.config.set(prop, settings[prop]);
- }
- });
- })
- .then(function() {
- events.emit('log', 'Fetching plugin "' + plugin + '" via npm');
- return Q.ninvoke(npm.commands, 'cache', ['add', plugin]);
- })
- .then(function(info) {
- var cl = (client === 'plugman' ? 'plugman' : 'cordova-cli');
- bumpCounter(info, cl);
- var pluginDir = path.resolve(npm.cache, info.name, info.version, 'package');
- // Unpack the plugin that was added to the cache (CB-8154)
- var package_tgz = path.resolve(npm.cache, info.name, info.version, 'package.tgz');
- return unpack.unpackTgz(package_tgz, pluginDir);
- })
- .fail(function(error) {
- events.emit('log', 'Fetching from npm registry failed');
- return Q.reject(error);
- });
-}
-
-/**
- * @method fetchPlugReg
- * @param {Array} with one element - the plugin id or "id@version"
- * @return {Promise.<string>} Promised path to fetched package.
- */
-function fetchPlugReg(plugin, client) {
- return initSettings()
+* @param {Array} with one element - the plugin id or "id@version"
+* @param useNpmRegistry: {Boolean} - to use the npm registry
+* @return {Promise.<string>} Promised path to fetched package.
+*/
+function fetchPlugin(plugin, client, useNpmRegistry) {
+ //set registry variable to use in log messages below
+ var registryName;
+ if(useNpmRegistry){
+ registryName = 'npm';
+ } else {
+ registryName = 'cordova plugins registry';
+ }
+ return initSettings(useNpmRegistry)
.then(function (settings) {
return Q.nfcall(npm.load)
// configure npm here instead of passing parameters to npm.load due to CB-7670
@@ -389,7 +361,7 @@ function fetchPlugReg(plugin, client) {
});
})
.then(function() {
- events.emit('log', 'Fetching plugin "' + plugin + '" via plugin registry');
+ events.emit('log', 'Fetching plugin "' + plugin + '" via ' + registryName);
return Q.ninvoke(npm.commands, 'cache', ['add', plugin]);
})
.then(function(info) {
@@ -401,7 +373,7 @@ function fetchPlugReg(plugin, client) {
return unpack.unpackTgz(package_tgz, pluginDir);
})
.fail(function(error) {
- events.emit('log', 'Fetching from cordova plugin registry failed');
+ events.emit('log', 'Fetching from ' + registryName + ' failed');
return Q.reject(error);
});
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org