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 2013/07/25 01:07:26 UTC
[06/23] git commit: Revert "[CB-4270] [BlackBerry10] Remove custom
emulate logic (moving to cordova-blackberry)"
Revert "[CB-4270] [BlackBerry10] Remove custom emulate logic (moving to cordova-blackberry)"
This reverts commit 2782d5ece23c1536239f4c9944179926709298b2.
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/4b15c456
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/4b15c456
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/4b15c456
Branch: refs/heads/plugman-registry
Commit: 4b15c4565765e62798221ea4bf6a507ddcb809dc
Parents: 5a40a4c
Author: Fil Maj <ma...@gmail.com>
Authored: Tue Jul 16 12:09:49 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Tue Jul 16 12:09:49 2013 -0700
----------------------------------------------------------------------
spec/emulate.spec.js | 21 +++++++++++++++++++++
src/emulate.js | 14 ++++++++++++++
2 files changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4b15c456/spec/emulate.spec.js
----------------------------------------------------------------------
diff --git a/spec/emulate.spec.js b/spec/emulate.spec.js
index 03151e3..d9f505f 100644
--- a/spec/emulate.spec.js
+++ b/spec/emulate.spec.js
@@ -54,6 +54,15 @@ describe('emulate command', function() {
cordova.emulate();
}).toThrow('Current working directory is not a Cordova-based project.');
});
+ it('should throw if no BlackBerry simulator targets exist and blackberry is to be emulated', function() {
+ var bb_project = path.join(project_dir, 'platforms', 'blackberry');
+ spyOn(platforms.blackberry, 'parser').andReturn({
+ has_simulator_target:function() { return false; }
+ });
+ expect(function() {
+ cordova.emulate('blackberry');
+ }).toThrow('No BlackBerry simulator targets defined. If you want to run emulate with BB10, please add a simulator target. For more information run "' + path.join(bb_project, 'cordova', 'target') + '" -h');
+ });
});
describe('success', function() {
@@ -65,6 +74,18 @@ describe('emulate command', function() {
done();
});
});
+ it('should execute a different BlackBerry-specific command to emulate blackberry', function() {
+ var bb_project = path.join(project_dir, 'platforms', 'blackberry');
+ spyOn(platforms.blackberry, 'parser').andReturn({
+ has_simulator_target:function() { return true; },
+ get_simulator_targets:function() { return [{name:'fifi'}]; },
+ get_cordova_config:function() { return {signing_password:'secret'}; }
+ });
+ expect(function() {
+ cordova.emulate('blackberry');
+ expect(exec.mostRecentCall.args[0]).toMatch(/blackberry.cordova.run" --target=fifi -k secret/gi);
+ }).not.toThrow();
+ });
});
describe('hooks', function() {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4b15c456/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
index b9cbe70..d41d01c 100644
--- a/src/emulate.js
+++ b/src/emulate.js
@@ -29,6 +29,20 @@ var cordova_util = require('./util'),
function shell_out_to_emulate(root, platform, error_callback, done) {
var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'run') + '" --emulator';
+ // TODO: inconsistent API for BB10 run command
+ if (platform == 'blackberry') {
+ var bb_project = path.join(root, 'platforms', 'blackberry')
+ var project = new platforms.blackberry.parser(bb_project);
+ if (project.has_simulator_target()) {
+ var bb_config = project.get_cordova_config();
+ var sim = project.get_simulator_targets()[0].name;
+ cmd = '"' + path.join(bb_project, 'cordova', 'run') + '" --target=' + sim + ' -k ' + bb_config.signing_password;
+ } else {
+ var err = new Error('No BlackBerry simulator targets defined. If you want to run emulate with BB10, please add a simulator target. For more information run "' + path.join(bb_project, 'cordova', 'target') + '" -h');
+ if (error_callback) return error_callback(err);
+ else throw err;
+ }
+ }
events.emit('log', 'Running on emulator for platform "' + platform + '" via command "' + cmd + '" (output to follow)...');
shell.exec(cmd, {silent:true, async:true}, function(code, output) {
events.emit('log', output);