You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/11/01 23:25:01 UTC

[2/4] git commit: Fixes #61: hook folders that do not exist blow things up. Now ignore hook folders that no longer exist.

Fixes #61: hook folders that do not exist blow things up. Now ignore hook folders that no longer exist.


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

Branch: refs/heads/cordova-client
Commit: de96a57782862263d89f5ba509f02de125fe99b7
Parents: 5f8f2a3
Author: Fil Maj <ma...@gmail.com>
Authored: Thu Nov 1 15:19:52 2012 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Nov 1 15:19:52 2012 -0700

----------------------------------------------------------------------
 spec/hooker.spec.js |    4 ++--
 src/hooker.js       |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/de96a577/spec/hooker.spec.js
----------------------------------------------------------------------
diff --git a/spec/hooker.spec.js b/spec/hooker.spec.js
index 8ba1a58..b6bea95 100644
--- a/spec/hooker.spec.js
+++ b/spec/hooker.spec.js
@@ -42,10 +42,10 @@ describe('hooker', function() {
         });
 
         describe('failure', function() {
-            it('should throw if the hook is unrecognized', function() {
+            it('should not throw if the hook is unrecognized', function() {
                 expect(function() {
                     h.fire('CLEAN YOUR SHORTS GODDAMNIT LIKE A BIG BOY!');
-                }).toThrow();
+                }).not.toThrow();
             });
             it('should throw if any script exits with non-zero code', function() {
                 var script = path.join(tempDir, '.cordova', 'hooks', 'before_build', 'fail.sh');

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/de96a577/src/hooker.js
----------------------------------------------------------------------
diff --git a/src/hooker.js b/src/hooker.js
index e01d9e2..d7b2e0b 100644
--- a/src/hooker.js
+++ b/src/hooker.js
@@ -13,7 +13,7 @@ module.exports = function hooker(root) {
 module.exports.prototype = {
     fire:function fire(hook) {
         var dir = path.join(this.root, '.cordova', 'hooks', hook);
-        if (!(fs.existsSync(dir))) throw 'Unrecognized hook "' + hook + '".';
+        if (!(fs.existsSync(dir))) return true; // hooks directory got axed post-create; ignore.
 
         // Fire JS hook/event
         events.emit(hook);