incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [1/2] git commit: landed module-level events/hooks. tweaks to tests
Date Sat, 06 Oct 2012 01:50:13 GMT
Updated Branches:
  refs/heads/cordova-client e9ac57dfc -> 79407964b


landed module-level events/hooks. tweaks to tests


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/79407964
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/79407964
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/79407964

Branch: refs/heads/cordova-client
Commit: 79407964b68e5cce6c3096e3b5b931749d5beff2
Parents: 487cbb3
Author: Fil Maj <maj.fil@gmail.com>
Authored: Fri Oct 5 18:49:34 2012 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Fri Oct 5 18:49:34 2012 -0700

----------------------------------------------------------------------
 cordova.js                 |   10 +++++++++-
 spec/build.spec.js         |    4 +++-
 spec/config_parser.spec.js |    6 +++---
 src/docs.js                |    3 +++
 src/hooker.js              |    6 ++++++
 5 files changed, 24 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/79407964/cordova.js
----------------------------------------------------------------------
diff --git a/cordova.js b/cordova.js
index e3149cc..a822479 100755
--- a/cordova.js
+++ b/cordova.js
@@ -1,3 +1,5 @@
+var cordova_events = require('./src/events');
+
 module.exports = {
     help:     require('./src/help'),
     docs:     require('./src/docs'),
@@ -5,5 +7,11 @@ module.exports = {
     platform: require('./src/platform'),
     build:    require('./src/build'),
     emulate:  require('./src/emulate'),
-    plugin:   require('./src/plugin')
+    plugin:   require('./src/plugin'),
+    on:       function() {
+        cordova_events.on.apply(cordova_events, arguments);
+    },
+    emit:     function() {
+        cordova_events.emit.apply(cordova_events, arguments);
+    }
 };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/79407964/spec/build.spec.js
----------------------------------------------------------------------
diff --git a/spec/build.spec.js b/spec/build.spec.js
index f0c4c0e..b2d4112 100644
--- a/spec/build.spec.js
+++ b/spec/build.spec.js
@@ -17,9 +17,11 @@ var cwd = process.cwd();
 describe('build command', function() {
     beforeEach(function() {
         // Make a temp directory
-        shell.rm('-rf', tempDir);
         shell.mkdir('-p', tempDir);
     });
+    afterEach(function() {
+        shell.rm('-rf', tempDir);
+    });
 
     it('should not run inside a Cordova-based project with no added platforms', function()
{
         this.after(function() {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/79407964/spec/config_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/config_parser.spec.js b/spec/config_parser.spec.js
index 4fa28a7..74c9067 100644
--- a/spec/config_parser.spec.js
+++ b/spec/config_parser.spec.js
@@ -9,11 +9,11 @@ var cordova = require('../cordova'),
 
 describe('config.xml parser', function () {
     beforeEach(function() {
-        // Make a temp directory
-        shell.rm('-rf', tempDir);
-        shell.mkdir('-p', tempDir);
         cordova.create(tempDir);
     });
+    afterEach(function() {
+        shell.rm('-rf', tempDir);
+    });
 
     it('should create an instance based on an xml file', function() {
         var cfg;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/79407964/src/docs.js
----------------------------------------------------------------------
diff --git a/src/docs.js b/src/docs.js
index db734af..75c070f 100644
--- a/src/docs.js
+++ b/src/docs.js
@@ -1,11 +1,13 @@
 var express = require('express'),
     path    = require('path'),
     colors  = require('colors'),
+    events  = require('./events'),
     port    = 2222,
     statik  = path.join(__dirname, '..', 'doc'),
     server  = express();
 
 module.exports = function docs () {
+    events.emit('before_docs');
     server.configure(function() {
         server.use(express['static'](statik));
         server.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
@@ -18,4 +20,5 @@ module.exports = function docs () {
     console.log("\nServing Cordova/Docs at: ".grey + 'http://localhost:2222'.blue.underline
+ "\n");
     console.log('Hit ctrl + c to terminate the process.'.cyan);
     server.listen(parseInt(port, 10));
+    events.emit('after_docs');
 };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/79407964/src/hooker.js
----------------------------------------------------------------------
diff --git a/src/hooker.js b/src/hooker.js
index 4fbad53..e01d9e2 100644
--- a/src/hooker.js
+++ b/src/hooker.js
@@ -1,6 +1,7 @@
 var shell = require('shelljs'),
     util  = require('./util'),
     fs    = require('fs'),
+    events= require('./events'),
     path  = require('path');
 
 module.exports = function hooker(root) {
@@ -13,6 +14,11 @@ module.exports.prototype = {
     fire:function fire(hook) {
         var dir = path.join(this.root, '.cordova', 'hooks', hook);
         if (!(fs.existsSync(dir))) throw 'Unrecognized hook "' + hook + '".';
+
+        // Fire JS hook/event
+        events.emit(hook);
+
+        // Fire script-based hooks
         var contents = fs.readdirSync(dir);
         contents.forEach(function(script) {
             var status = shell.exec(path.join(dir, script));


Mime
View raw message