cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lorinb...@apache.org
Subject [2/5] git commit: [CB-6293] dual return method implemented in run
Date Mon, 17 Mar 2014 21:20:02 GMT
[CB-6293] dual return method implemented in run

non-breaking support of promises and callbacks


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

Branch: refs/heads/master
Commit: f1b57373411f4cd5fd399ad341c163b6fc54620b
Parents: 2a7cac3
Author: lorinbeer <lorin@adobe.com>
Authored: Mon Mar 17 13:34:58 2014 -0700
Committer: lorinbeer <lorin@adobe.com>
Committed: Mon Mar 17 13:34:58 2014 -0700

----------------------------------------------------------------------
 src/run.js | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f1b57373/src/run.js
----------------------------------------------------------------------
diff --git a/src/run.js b/src/run.js
index 5de3031..fd1044f 100644
--- a/src/run.js
+++ b/src/run.js
@@ -27,12 +27,13 @@ var cordova_util      = require('./util'),
     Q                 = require('q');
 
 // Returns a promise.
-module.exports = function run(options) {
+module.exports = function run(options, callback) {
     var projectRoot = cordova_util.cdProjectRoot(),
-    options = cordova_util.preProcessOptions(options);
+        options = cordova_util.preProcessOptions(options),
+        ret = null;
 
     var hooks = new hooker(projectRoot);
-    return hooks.fire('before_run', options)
+    ret = hooks.fire('before_run', options)
     .then(function() {
         // Run a prepare first, then shell out to run
         return require('../cordova').raw.prepare(options.platforms)
@@ -44,5 +45,15 @@ module.exports = function run(options) {
         }));
     }).then(function() {
         return hooks.fire('after_run', options);
+    }).then(function() {
+        if (callback) {
+            callback();
+        }
     });
+    // returns null if callback is a valid parameter
+    if (callback) {
+        return null;
+    }
+
+    return ret;
 };


Mime
View raw message