Skip to content
Browse files

Don't do a git pull unless it's a github post hook.

  • Loading branch information...
1 parent 90d7957 commit 0cd7281534d170c390e77a12b2bbf3bc8ca5e40d @creationix committed Feb 2, 2010
Showing with 18 additions and 26 deletions.
  1. +18 −26 builder.js
View
44 builder.js
@@ -3,6 +3,7 @@ var Markdown = require('markdown'),
Http = require('http'),
Build = require('./build');
process.mixin(require('sys'));
+var PORT = 4242;
Http.createServer(function (req, res) {
var body = "";
@@ -11,37 +12,28 @@ Http.createServer(function (req, res) {
body += chunk;
});
req.addListener('complete', function () {
- // try {
- // puts(body);
- // body = Url.parse("?" + body, true).query.payload;
- // puts(body);
- // body = JSON.parse(body);
- // } catch(e) {
- // res.sendHeader(500, {'Content-Type': 'text/plain'});
- // res.sendBody('Problem reading post message!\n' + e.stack);
- //
- // res.finish();
- // return;
- // }
try {
- build(body);
- res.sendHeader(200, {'Content-Type': 'text/plain'});
- res.sendBody('Thanks for the tip!');
- res.finish();
+ body = Url.parse("?" + body, true).query.payload;
+ body = JSON.parse(body);
} catch(e) {
- res.sendHeader(500, {'Content-Type': 'text/plain'});
- res.sendBody(e.stack);
- res.finish();
+ body = false;
}
+ build(body);
+ res.sendHeader(200, {'Content-Type': 'text/plain'});
+ res.sendBody('Thanks for the tip!');
+ res.finish();
});
-}).listen(4242);
+}).listen(PORT);
-function build(data) {
- p(data);
- exec("cd data && git pull origin master").addCallback(function (stdout, stderr) {
- puts(stdout);
+function build(pull) {
+ if (pull) {
+ exec("cd data && git pull origin master").addCallback(function (stdout, stderr) {
+ puts(stdout);
+ Build.build();
+ });
+ } else {
Build.build();
- });
+ }
}
-puts('Server running at http://127.0.0.1:4242/');
+puts('Server running at http://127.0.0.1:' + PORT + '/');

0 comments on commit 0cd7281

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