You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ka...@apache.org on 2014/06/06 03:24:58 UTC

git commit: CB-6024: Accept cli vars as part of opts param

Repository: cordova-lib
Updated Branches:
  refs/heads/master 68ddfdb19 -> d8a971735


CB-6024: Accept cli vars as part of opts param

This is part of the nopt refacoring in cordova-cli. The old spaghetti logic
for extracting options and variables from the arguments is kept, but should
probably be removed soon.


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

Branch: refs/heads/master
Commit: d8a971735bfc2da4a90fcd9f27345e29305c57cf
Parents: 68ddfdb
Author: Mark Koudritsky <ka...@gmail.com>
Authored: Thu Jun 5 18:31:46 2014 -0400
Committer: Mark Koudritsky <ka...@gmail.com>
Committed: Thu Jun 5 18:31:46 2014 -0400

----------------------------------------------------------------------
 cordova-lib/src/cordova/plugin.js | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d8a97173/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index f9be60c..0575072 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -46,7 +46,7 @@ module.exports = function plugin(command, targets, opts) {
     targets = targets || [];
     opts = opts || {};
     if ( opts.length ) {
-        // This is the case with multiple targes as separate arguments and opts is not opts but another target.
+        // This is the case with multiple targets as separate arguments and opts is not opts but another target.
         targets = Array.prototype.slice.call(arguments, 1);
         opts = {};
     }
@@ -54,7 +54,7 @@ module.exports = function plugin(command, targets, opts) {
         // This means we had a single target given as string.
         targets = [targets];
     }
-    opts.options = [];
+    opts.options = opts.options || [];
     opts.plugins = [];
 
     var hooks = new hooker(projectRoot);
@@ -124,12 +124,15 @@ module.exports = function plugin(command, targets, opts) {
                                 var platformRoot = path.join(projectRoot, 'platforms', platform),
                                     parser = new platforms[platform].parser(platformRoot),
                                     options = {
-                                        cli_variables: {},
+                                        cli_variables: opts.cli_variables || {},
                                         searchpath: searchPath
                                     },
                                     tokens,
                                     key,
                                     i;
+
+                                // TODO: Remove this. CLI vars are passed as part of the opts object after "nopt" refactoring.
+                                // Keeping for now for compatibility for API users.
                                 //parse variables into cli_variables
                                 for (i=0; i< opts.options.length; i++) {
                                     if (opts.options[i] === "--variable" && typeof opts.options[++i] === "string") {