You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2016/04/11 15:50:29 UTC

cordova-lib git commit: CB-10921 Emit warning in case of plugin restoration failure

Repository: cordova-lib
Updated Branches:
  refs/heads/master 5737d74b2 -> 0f06507c4


CB-10921 Emit warning in case of plugin restoration failure

This closes #420


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

Branch: refs/heads/master
Commit: 0f06507c4f5b851e201ebfccd57615dba21b7151
Parents: 5737d74
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Thu Mar 31 14:25:27 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Mon Apr 11 16:49:01 2016 +0300

----------------------------------------------------------------------
 cordova-lib/src/cordova/plugin.js       |  1 +
 cordova-lib/src/cordova/restore-util.js | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0f06507c/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index b4d47dc..87d5c74 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -156,6 +156,7 @@ module.exports = function plugin(command, targets, opts) {
                             });
 
                             if (missingVariables.length) {
+                                events.emit('verbose', 'Removing ' + pluginInfo.dir + ' due to installation failure');
                                 shell.rm('-rf', pluginInfo.dir);
                                 var msg = 'Variable(s) missing (use: --variable ' + missingVariables.join('=value --variable ') + '=value).';
                                 return Q.reject(new CordovaError(msg));

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0f06507c/cordova-lib/src/cordova/restore-util.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/restore-util.js b/cordova-lib/src/cordova/restore-util.js
index 102e302..9b0f585 100644
--- a/cordova-lib/src/cordova/restore-util.js
+++ b/cordova-lib/src/cordova/restore-util.js
@@ -90,6 +90,11 @@ function installPluginsFromConfigXML(args) {
         return Q('No config.xml plugins to install');
     }
 
+
+    // Intermediate variable to store current installing plugin name
+    // to be able to create informative warning on plugin failure
+    var pluginName;
+
     // CB-9560 : Run `plugin add` serially, one plugin after another
     // We need to wait for the plugin and its dependencies to be installed
     // before installing the next root plugin otherwise we can have common
@@ -106,7 +111,8 @@ function installPluginsFromConfigXML(args) {
         // Install from given URL if defined or using a plugin id. If spec isn't a valid version or version range,
         // assume it is the location to install from.
         var pluginSpec = pluginEntry.spec;
-        var installFrom = semver.validRange(pluginSpec, true) ? pluginEntry.name + '@' + pluginSpec : pluginSpec;
+        pluginName = pluginEntry.name;
+        var installFrom = semver.validRange(pluginSpec, true) ? pluginName + '@' + pluginSpec : pluginSpec;
 
         // Add feature preferences as CLI variables if have any
         var options = {
@@ -114,5 +120,10 @@ function installPluginsFromConfigXML(args) {
             searchpath: args.searchpath
         };
         return plugin('add', installFrom, options);
+    }, function (error) {
+        // CB-10921 emit a warning in case of error
+        var msg = 'Failed to restore plugin ' + pluginName + ' from config.xml. ' +
+            'You might want to reinstall it again. Error: ' + error;
+        events.emit('warn', msg);
     });
 }


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