Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DA985DCDF for ; Wed, 28 Nov 2012 18:16:27 +0000 (UTC) Received: (qmail 72474 invoked by uid 500); 28 Nov 2012 18:16:25 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 72348 invoked by uid 500); 28 Nov 2012 18:16:25 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 71302 invoked by uid 99); 28 Nov 2012 18:16:24 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Nov 2012 18:16:24 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 76B79812F7C; Wed, 28 Nov 2012 18:16:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: filmaj@apache.org To: commits@cordova.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [43/50] git commit: landed module-level events/hooks. tweaks to tests Message-Id: <20121128181624.76B79812F7C@tyr.zones.apache.org> Date: Wed, 28 Nov 2012 18:16:24 +0000 (UTC) landed module-level events/hooks. tweaks to tests Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/79407964 Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/79407964 Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/79407964 Branch: refs/heads/master Commit: 79407964b68e5cce6c3096e3b5b931749d5beff2 Parents: 487cbb3 Author: Fil Maj Authored: Fri Oct 5 18:49:34 2012 -0700 Committer: Fil Maj 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/cordova-cli/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/cordova-cli/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/cordova-cli/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/cordova-cli/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/cordova-cli/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));