Skip to content
Browse files

Add hook function to post-receive

  • Loading branch information...
1 parent d37790a commit 22659ef830a11b26f3c804fc77a3bdb0bea94489 @creationix committed Dec 29, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 postReceive.js
View
8 postReceive.js
@@ -3,7 +3,7 @@ var ChildProcess = require('child_process');
var QueryString = require('querystring');
// Handler for github post-receive hooks
-module.exports = function setup(mount, script) {
+module.exports = function setup(mount, script, hook) {
return function handle(req, res, next) {
if (req.method !== "POST") return next();
if (!req.hasOwnProperty("uri")) { req.uri = Url.parse(req.url); }
@@ -18,13 +18,15 @@ module.exports = function setup(mount, script) {
try {
data = QueryString.parse(data);
message = JSON.parse(data.payload);
- console.log(message)
} catch (err) {
- return next(err);
+ message = {};
}
ChildProcess.execFile(script, [], {}, function (err, stdout, stderr) {
if (err) return next(err);
var body = stdout + stderr;
+ process.stdout.write(stdout);
+ process.stderr.write(stderr);
+ if (hook) hook();
res.writeHead(200, {"Content-Length": Buffer.byteLength(body)});
res.end(body);
});

0 comments on commit 22659ef

Please sign in to comment.
Something went wrong with that request. Please try again.