Updated Branches:
  refs/heads/master2 eb6cbf9ab -> f53f6ea32

2.8.20. [CB-3929] Fixed data object passed into module-level hooks. Also added 
"paths" property to data object that prepare sends to the module-level hooks


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

Branch: refs/heads/master2
Commit: f53f6ea321167f66458a53a56fb8a484cb72ea89
Parents: eb6cbf9
Author: Fil Maj <[email protected]>
Authored: Tue Jun 18 14:34:38 2013 -0700
Committer: Fil Maj <[email protected]>
Committed: Tue Jun 18 14:34:38 2013 -0700

----------------------------------------------------------------------
 package.json         |  2 +-
 spec/hooker.spec.js  | 31 ++++++++++++++++++++++++++++++-
 spec/prepare.spec.js | 14 ++++++++------
 src/hooker.js        |  2 +-
 src/prepare.js       |  6 ++++++
 5 files changed, 46 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f53f6ea3/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 24549a2..47a4b10 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.19",
+  "version": "2.8.20",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f53f6ea3/spec/hooker.spec.js
----------------------------------------------------------------------
diff --git a/spec/hooker.spec.js b/spec/hooker.spec.js
index 2fe1705..a85fc88 100644
--- a/spec/hooker.spec.js
+++ b/spec/hooker.spec.js
@@ -168,7 +168,7 @@ describe('hooker', function() {
                 var handler = jasmine.createSpy();
                 var test_event = 'before_build';
                 afterEach(function() {
-                    cordova.off(test_event, handler);
+                    cordova.removeAllListeners(test_event);
                     handler.reset();
                 });
 
@@ -221,6 +221,35 @@ describe('hooker', function() {
                         expect(h2_fired).toBe(true);
                     });
                 });
+                it('should pass data object that fire calls into async 
handlers', function(done) {
+                    var data = {
+                        "hi":"ho",
+                        "offtowork":"wego"
+                    };
+                    var async = function(opts, cb) {
+                        data.root = tempDir;
+                        expect(opts).toEqual(data);
+                        cb();
+                    };
+                    cordova.on(test_event, async);
+                    h.fire(test_event, data, function() {
+                        done();
+                    });
+                });
+                it('should pass data object that fire calls into sync 
handlers', function(done) {
+                    var data = {
+                        "hi":"ho",
+                        "offtowork":"wego"
+                    };
+                    var async = function(opts) {
+                        data.root = tempDir;
+                        expect(opts).toEqual(data);
+                    };
+                    cordova.on(test_event, async);
+                    h.fire(test_event, data, function() {
+                        done();
+                    });
+                });
             });
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f53f6ea3/spec/prepare.spec.js
----------------------------------------------------------------------
diff --git a/spec/prepare.spec.js b/spec/prepare.spec.js
index 671213c..2f3921c 100644
--- a/spec/prepare.spec.js
+++ b/spec/prepare.spec.js
@@ -27,11 +27,12 @@ var cordova = require('../cordova'),
     fixtures = path.join(__dirname, 'fixtures'),
     hooks = path.join(fixtures, 'hooks');
 
+var project_dir = '/some/path';
 var supported_platforms = Object.keys(platforms).filter(function(p) { return p 
!= 'www'; });
+var supported_platforms_paths = supported_platforms.map(function(p) { return 
path.join(project_dir, 'platforms', p, 'www'); }); 
 
 describe('prepare command', function() {
     var is_cordova, list_platforms, fire, config_parser, parsers = {}, 
plugman_prepare, find_plugins, plugman_get_json;
-    var project_dir = '/some/path';
     beforeEach(function() {
         is_cordova = spyOn(util, 'isCordova').andReturn(project_dir);
         list_platforms = spyOn(util, 
'listPlatforms').andReturn(supported_platforms);
@@ -44,7 +45,8 @@ describe('prepare command', function() {
                 cb();
             });
             spyOn(platforms[p], 'parser').andReturn({
-                update_project:parsers[p]
+                update_project:parsers[p],
+                www_dir:function() { return path.join(project_dir, 
'platforms', p, 'www'); }
             });
         });
         plugman_prepare = spyOn(plugman, 'prepare');
@@ -113,13 +115,13 @@ describe('prepare command', function() {
 
     describe('hooks', function() {
         describe('when platforms are added', function() {
-            it('should fire before hooks through the hooker module', 
function() {
+            it('should fire before hooks through the hooker module, and pass 
in platforms and paths as data object', function() {
                 cordova.prepare();
-                expect(fire).toHaveBeenCalledWith('before_prepare', 
{platforms:supported_platforms}, jasmine.any(Function));
+                expect(fire).toHaveBeenCalledWith('before_prepare', 
{platforms:supported_platforms, paths:supported_platforms_paths}, 
jasmine.any(Function));
             });
-            it('should fire after hooks through the hooker module', 
function(done) {
+            it('should fire after hooks through the hooker module, and pass in 
platforms and paths as data object', function(done) {
                 cordova.prepare('android', function() {
-                     expect(fire).toHaveBeenCalledWith('after_prepare', 
{platforms:['android']}, jasmine.any(Function));
+                     expect(fire).toHaveBeenCalledWith('after_prepare', 
{platforms:['android'], paths:[path.join(project_dir, 'platforms', 'android', 
'www')]}, jasmine.any(Function));
                      done();
                 });
             });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f53f6ea3/src/hooker.js
----------------------------------------------------------------------
diff --git a/src/hooker.js b/src/hooker.js
index cdd44d9..b5e39d4 100644
--- a/src/hooker.js
+++ b/src/hooker.js
@@ -97,7 +97,7 @@ function execute_handlers_serially(handlers, opts, callback) {
     if (handlers.length) {
         var h = handlers.shift();
         if (h.length > 1) {
-            h(root, function() {
+            h(opts, function() {
                 execute_handlers_serially(handlers, opts, callback);
             });
         } else {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f53f6ea3/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 6632efb..f7c9d11 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -60,6 +60,12 @@ module.exports = function prepare(platformList, callback) {
     var opts = {
         platforms:platformList
     };
+    var paths = platformList.map(function(p) {
+        var platform_path = path.join(projectRoot, 'platforms', p);
+        var parser = (new platforms[p].parser(platform_path));
+        return parser.www_dir();
+    });
+    opts.paths = paths;
 
     var hooks = new hooker(projectRoot);
     hooks.fire('before_prepare', opts, function(err) {

Reply via email to