Permalink
Browse files

moved vent exposure from middleware to module.exports

  • Loading branch information...
1 parent 34c2598 commit 210fdb4368277c79bb569b304d6e7b8c2b9e84f6 @coen-hyde committed Jan 4, 2013
Showing with 25 additions and 25 deletions.
  1. +24 −24 index.js
  2. +1 −1 package.json
View
@@ -1,29 +1,11 @@
var path = require('path')
, fs = require('fs')
- , EventEmitter = require('events').EventEmitter;
+ , EventEmitter = require('events').EventEmitter
+ , building = false
+ , vent = new EventEmitter();
-module.exports = function(projectRoot) {
+hanger = function(projectRoot) {
var buildFile = path.resolve(projectRoot)+'/.grunthang'
- , building = false
- , vent = new EventEmitter();
-
- vent.on('build:start', function() {
- building = true;
- });
-
- vent.on('build:end', function() {
- building = false;
- });
-
- var middleware = function(req, res, next) {
- if (!building) {
- return next();
- }
-
- vent.once('build:end', next);
- };
-
- middleware.vent = vent;
if (!fs.existsSync(buildFile)) {
fs.writeFileSync(buildFile, '-');
@@ -40,5 +22,23 @@ module.exports = function(projectRoot) {
}
});
- return middleware;
-};
+ return function(req, res, next) {
+ if (!building) {
+ return next();
+ }
+
+ vent.once('build:end', next);
+ };
+};
+
+vent.on('build:start', function() {
+ building = true;
+});
+
+vent.on('build:end', function() {
+ building = false;
+});
+
+hanger.vent = vent;
+
+module.exports = hanger;
View
@@ -6,7 +6,7 @@
"name": "Coen Hyde",
"url": "http://coenhyde.com/"
},
- "version": "0.1.1",
+ "version": "0.1.2",
"repository": {
"type": "git",
"url": "git://github.com/coen-hyde/grunt-hang.git"

0 comments on commit 210fdb4

Please sign in to comment.