You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2014/10/02 17:13:38 UTC

git commit: CB-7698 CLI - Validate top-level plugin variables before installing

Repository: cordova-lib
Updated Branches:
  refs/heads/master c3657efa8 -> 242a8d760


CB-7698 CLI - Validate top-level plugin variables before installing


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

Branch: refs/heads/master
Commit: 242a8d760267379e963977de68d49aae96928562
Parents: c3657ef
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Thu Oct 2 11:09:33 2014 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Thu Oct 2 11:09:33 2014 -0400

----------------------------------------------------------------------
 cordova-lib/src/cordova/plugin.js | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/242a8d76/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index 6763560..4c2cccf 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -29,6 +29,7 @@ var cordova_util  = require('./util'),
     CordovaError  = require('../CordovaError'),
     ConfigParser  = require('../configparser/ConfigParser'),
     fs            = require('fs'),
+    shell         = require('shelljs'),
     PluginInfo    = require('../PluginInfo'),
     plugman       = require('../plugman/plugman'),
     events        = require('../events');
@@ -121,6 +122,16 @@ module.exports = function plugin(command, targets, opts) {
                         return plugman.raw.fetch(target, pluginsDir, { searchpath: searchPath, noregistry: opts.noregistry});
                     })
                     .then(function(dir) {
+                        // Validate top-level required variables
+                        var pluginVariables = new PluginInfo.PluginInfo(dir).getPreferences(),
+                            missingVariables = pluginVariables.filter(function (v) {
+                                return !(v in opts.cli_variables);
+                            });
+                        if (missingVariables.length) {
+                            shell.rm('-rf', dir);
+                            events.emit('results', 'Variable(s) missing (use: --variable ' + missingVariables.join('=value --variable ') + '=value).');
+                            return;
+                        }
                         // Iterate (in serial!) over all platforms in the project and install the plugin.
                         return platformList.reduce(function(soFar, platform) {
                             return soFar.then(function() {