cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cordova-cli git commit: CB-9171 Support Plugin Variables with =
Date Mon, 15 Jun 2015 19:28:17 GMT
Repository: cordova-cli
Updated Branches:
  refs/heads/master 8014633b9 -> 5cb438d2e


CB-9171 Support Plugin Variables with =

This closes #217


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

Branch: refs/heads/master
Commit: 5cb438d2e0a851cadbc90dbfa605cd9f75be0ca5
Parents: 8014633
Author: Olivier Goguel <o@goguel.com>
Authored: Fri Jun 12 23:41:18 2015 +0200
Committer: Tim Barham <tim.barham@microsoft.com>
Committed: Mon Jun 15 12:27:30 2015 -0700

----------------------------------------------------------------------
 spec/cli.spec.js | 11 +++++++++++
 src/cli.js       | 12 ++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5cb438d2/spec/cli.spec.js
----------------------------------------------------------------------
diff --git a/spec/cli.spec.js b/spec/cli.spec.js
index 734791a..1cf0488 100644
--- a/spec/cli.spec.js
+++ b/spec/cli.spec.js
@@ -121,5 +121,16 @@ describe("cordova cli", function () {
             var opts = cordova.raw.plugin.calls[0].args[2];
             expect(opts.cli_variables.FOO).toBe('foo');
         });
+
+          it("will  support variables with =", function () {
+            cli(["node", "cordova", "plugin", "add", "facebook", "--variable", "MOTO=DELTA=WAS=HERE"]);
+            expect(cordova.raw.plugin).toHaveBeenCalledWith(
+                "add",
+                ["facebook"],
+                jasmine.any(Object)
+            );
+            var opts = cordova.raw.plugin.calls[0].args[2];
+            expect(opts.cli_variables.MOTO).toBe('DELTA=WAS=HERE');
+        });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5cb438d2/src/cli.js
----------------------------------------------------------------------
diff --git a/src/cli.js b/src/cli.js
index f0ae5d3..56379a5 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -338,10 +338,14 @@ function cli(inputArgs) {
         var targets = undashed.slice(2); // array of targets, either platforms or plugins
         var cli_vars = {};
         if (args.variable) {
-            args.variable.forEach( function(s) {
-                var keyval = s.split('=');
-                var key = keyval[0].toUpperCase();
-                cli_vars[key] = keyval[1];
+            args.variable.forEach(function (s) {
+                // CB-9171
+                var eq = s.indexOf('=');
+                if (eq == -1)
+                    throw new CordovaError("invalid variable format: " + s);
+                var key = s.substr(0, eq).toUpperCase();
+                var val = s.substr(eq + 1, s.length);
+                cli_vars[key] = val;
             });
         }
         var download_opts = { searchpath : args.searchpath


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


Mime
View raw message