You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2014/03/17 18:55:47 UTC
[1/2] git commit: pwd
Repository: cordova-cli
Updated Branches:
refs/heads/master 55a31889d -> 60f5e8d72
pwd
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/9b7324a4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/9b7324a4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/9b7324a4
Branch: refs/heads/master
Commit: 9b7324a46057bf10c117314ea200068b5473e21c
Parents: 55a3188
Author: lorinbeer <lo...@adobe.com>
Authored: Mon Mar 17 10:51:02 2014 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Mon Mar 17 10:51:02 2014 -0700
----------------------------------------------------------------------
src/build.js | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/9b7324a4/src/build.js
----------------------------------------------------------------------
diff --git a/src/build.js b/src/build.js
index 5a0f0d3..27b9d0a 100644
--- a/src/build.js
+++ b/src/build.js
@@ -21,8 +21,10 @@ var cordova_util = require('./util'),
hooker = require('./hooker');
// Returns a promise.
-module.exports = function build(options) {
- var projectRoot = cordova_util.cdProjectRoot();
+module.exports = function build(options, callback) {
+ var projectRoot = cordova_util.cdProjectRoot(),
+ cbmode = callback ? true : false,
+ ret = null;
if (!options) {
options = {
@@ -31,17 +33,26 @@ module.exports = function build(options) {
options: []
};
}
-
+
options = cordova_util.preProcessOptions(options);
// fire build hooks
var hooks = new hooker(projectRoot);
- return hooks.fire('before_build', options)
+ ret = hooks.fire('before_build', options)
.then(function() {
return require('../cordova').raw.prepare(options);
}).then(function() {
return require('../cordova').raw.compile(options);
}).then(function() {
return hooks.fire('after_build', options);
+ }).then(function() {
+ if(callback) {
+ callback();
+ }
});
+ // if we received a callback, returns null
+ if (callback) {
+ ret = null;
+ }
+ return ret;
};
[2/2] git commit: [CB-6292] tests for build function's dual return
method
Posted by lo...@apache.org.
[CB-6292] tests for build function's dual return method
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/60f5e8d7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/60f5e8d7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/60f5e8d7
Branch: refs/heads/master
Commit: 60f5e8d72e4e1a1446780e308815e4b07080c73d
Parents: 9b7324a
Author: lorinbeer <lo...@adobe.com>
Authored: Mon Mar 17 10:52:42 2014 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Mon Mar 17 10:52:42 2014 -0700
----------------------------------------------------------------------
spec/build.spec.js | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/60f5e8d7/spec/build.spec.js
----------------------------------------------------------------------
diff --git a/spec/build.spec.js b/spec/build.spec.js
index 259c3d4..c4c58d8 100644
--- a/spec/build.spec.js
+++ b/spec/build.spec.js
@@ -78,9 +78,37 @@ describe('build command', function() {
});
});
+ describe('callback',function() {
+ var tag = false,
+ promise,
+ callback;
+
+ beforeEach(function () {
+ callback = function() {
+ tag = true;
+ }
+ });
+
+ it('should return null if a callback argument is supplied',function(){
+ var promise;
+
+ promise = cordova.raw.build(['android','ios'], callback);
+ expect(promise).toBe(null);
+ });
+
+ it('should call the supplied callback if supplied', function() {
+ runs(function(){
+ cordova.raw.build(['android','ios'],callback);
+ });
+ waitsFor(function(){
+ return tag;
+ },10000);
+ });
+ });
+
describe('success', function() {
it('should run inside a Cordova-based project with at least one added platform and call both prepare and compile', function(done) {
- cordova.raw.build(['android','ios']).then(function() {
+ cordova.raw.build(['android','ios']).then(function() {
var opts = {verbose: false, platforms: ['android', 'ios'], options: []};
expect(prepare_spy).toHaveBeenCalledWith(opts);
expect(compile_spy).toHaveBeenCalledWith(opts);
@@ -97,6 +125,10 @@ describe('build command', function() {
});
});
+ describe('',function(){
+
+ });
+
describe('hooks', function() {
describe('when platforms are added', function() {
it('should fire before hooks through the hooker module', function(done) {