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/08/02 15:03:15 UTC

cordova-windows git commit: CB-11478 Parse --archs option consistently

Repository: cordova-windows
Updated Branches:
  refs/heads/master 43b101a6c -> 7ad7258f8


CB-11478 Parse --archs option consistently

Update arguments parsing logic to be consistent with build command
where passing --archs as CLI argument (cordova build --archs) or platform
arg, behind -- (cordova build -- --archs) doesn't make any difference


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

Branch: refs/heads/master
Commit: 7ad7258f81c7c0a37c5bf1c717491f377fe85b87
Parents: 43b101a
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Tue Aug 2 13:18:58 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Tue Aug 2 18:02:13 2016 +0300

----------------------------------------------------------------------
 spec/unit/run.spec.js       | 60 ++++++++++++++++++++++++++++++++++++++++
 template/cordova/lib/run.js | 15 ++++++----
 2 files changed, 70 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/7ad7258f/spec/unit/run.spec.js
----------------------------------------------------------------------
diff --git a/spec/unit/run.spec.js b/spec/unit/run.spec.js
index 5a2cbd7..6ffcda0 100644
--- a/spec/unit/run.spec.js
+++ b/spec/unit/run.spec.js
@@ -16,6 +16,7 @@
     specific language governing permissions and limitations
     under the License.
 */
+
 var Q = require('q'),
     path = require('path'),
     rewire = require('rewire'),
@@ -23,6 +24,9 @@ var Q = require('q'),
     buildPath = path.join(platformRoot, 'cordova', 'build'),
     run = rewire(platformRoot + '/cordova/lib/run.js');
 
+var utils = require(path.join(platformRoot, 'cordova/lib/utils'));
+var packages = require(path.join(platformRoot, 'cordova/lib/package'));
+
 describe('run method', function() {
     var consoleLogOriginal,
         isCordovaProjectOriginal,
@@ -244,4 +248,60 @@ describe('run method', function() {
             done();
         });
     });
+
+    it('spec.8 should accept --archs parameter either as cli or as platform arg', function(done) {
+
+        spyOn(utils, 'isCordovaProject').andReturn(true);
+        spyOn(packages, 'getPackage').andReturn(Q({ arch: 'arm' }));
+        spyOn(packages, 'deployToDesktop').andReturn(Q());
+
+        var anyString = jasmine.any(String);
+        var expectedDeployOptions = jasmine.objectContaining({arch: 'arm'});
+
+        var fail = jasmine.createSpy('fail')
+        .andCallFake(function (err) {
+            console.error(err);
+        });
+
+        run.run({nobuild: true, argv: ['--archs=arm'] })
+        .then(function () {
+            expect(packages.getPackage).toHaveBeenCalledWith(anyString, anyString, 'arm');
+            expect(packages.deployToDesktop).toHaveBeenCalledWith(expectedDeployOptions, anyString, anyString);
+        })
+        .then(function () {
+            return run.run({nobuild: true, archs: 'arm' });
+        })
+        .then(function () {
+            expect(packages.getPackage).toHaveBeenCalledWith(anyString, anyString, 'arm');
+            expect(packages.deployToDesktop).toHaveBeenCalledWith(expectedDeployOptions, anyString, anyString);
+        })
+        .catch(fail)
+        .finally(function() {
+            expect(fail).not.toHaveBeenCalled();
+            done();
+        });
+    });
+
+    it('spec.9 should fall back to anycpu if --archs parameter is not specified', function(done) {
+
+        spyOn(utils, 'isCordovaProject').andReturn(true);
+        spyOn(packages, 'getPackage').andReturn(Q({ arch: 'anycpu' }));
+        spyOn(packages, 'deployToDesktop').andReturn(Q());
+
+        var anyString = jasmine.any(String);
+        var expectedDeployOptions = jasmine.objectContaining({arch: 'anycpu'});
+
+        var fail = jasmine.createSpy('fail');
+
+        run.run({nobuild: true})
+        .then(function () {
+            expect(packages.getPackage).toHaveBeenCalledWith(anyString, anyString, 'anycpu');
+            expect(packages.deployToDesktop).toHaveBeenCalledWith(expectedDeployOptions, anyString, anyString);
+        })
+        .catch(fail)
+        .finally(function() {
+            expect(fail).not.toHaveBeenCalled();
+            done();
+        });
+    });
 });

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/7ad7258f/template/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/run.js b/template/cordova/lib/run.js
index f67bd20..b2f362c 100644
--- a/template/cordova/lib/run.js
+++ b/template/cordova/lib/run.js
@@ -39,7 +39,7 @@ module.exports.run = function (options) {
 
     // parse arg
     var args  = nopt({
-        'archs': String,
+        'archs': [String],
         'phone': Boolean,
         'win': Boolean,
         'appx': String,
@@ -58,9 +58,14 @@ module.exports.run = function (options) {
     }
 
     // Get build/deploy options
-    var buildType    = options.release ? 'release' : 'debug',
-        buildArchs   = args.archs ? args.archs.split(' ') : ['anycpu'],
-        deployTarget = options.target ? options.target : (options.emulator ? 'emulator' : 'device');
+    var buildType    = options.release ? 'release' : 'debug';
+    // CB-11478 Allow to specify 'archs' parameter as either cli or platform
+    // option i.e. 'cordova run --archs' vs. 'cordova run -- --archs'
+    var archs = options.archs || args.archs || ['anycpu'];
+    if (typeof archs === 'string') { archs = archs.split(' '); }
+
+    var buildArchs = archs.map(function (arch) { return arch.toLowerCase(); });
+    var deployTarget = options.target ? options.target : (options.emulator ? 'emulator' : 'device');
 
      var buildTargets = build.getBuildTargets(args.win, args.phone, args.appx);
 
@@ -73,7 +78,7 @@ module.exports.run = function (options) {
      var projectType = projFileToType(buildTargets[0]);
 
     // if --nobuild isn't specified then build app first
-    var buildPackages = options.nobuild ? packages.getPackage(projectType, buildType, buildArchs) : build.run.call(this, options);
+    var buildPackages = options.nobuild ? packages.getPackage(projectType, buildType, buildArchs[0]) : build.run.call(this, options);
 
     // buildPackages also deploys bundles
     return buildPackages


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