Permalink
Browse files

Hook up the builder to the github hook.

  • Loading branch information...
1 parent bb5bbf9 commit 27b70f0f1d496cae6dce93ddc29ac86c8a20f65b @creationix committed Feb 2, 2010
Showing with 30 additions and 23 deletions.
  1. +9 −10 build.js
  2. +21 −13 builder.js
View
@@ -1,6 +1,3 @@
-// Define puts and friends
-process.mixin(require('sys'));
-
// Load some libraries
var Haml = require('haml'),
Markdown = require('markdown'),
@@ -168,10 +165,12 @@ function render(data) {
}));
}
-// Kick off the process
-main([
- ["articles", ARTICLE_DIR, /^(.*)\.(markdown)$/],
- ["authors", AUTHOR_DIR, /^(.*)\.(markdown)$/],
- ["templates", SKIN_DIR, /^(.*)\.(haml)$/],
- ["static", SKIN_DIR, /^(.*)\.([^.]+)\.([^.]+)$/]
-], render);
+exports.build = function () {
+ // Kick off the process
+ main([
+ ["articles", ARTICLE_DIR, /^(.*)\.(markdown)$/],
+ ["authors", AUTHOR_DIR, /^(.*)\.(markdown)$/],
+ ["templates", SKIN_DIR, /^(.*)\.(haml)$/],
+ ["static", SKIN_DIR, /^(.*)\.([^.]+)\.([^.]+)$/]
+ ], render);
+};
View
@@ -1,6 +1,7 @@
var Markdown = require('markdown'),
Url = require('url'),
- Http = require('http');
+ Http = require('http'),
+ Build = require('./build');
process.mixin(require('sys'));
Http.createServer(function (req, res) {
@@ -10,30 +11,37 @@ 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 {
- puts(body);
- body = Url.parse("?" + body, true).query.payload;
- puts(body);
- body = JSON.parse(body);
+ build(body);
+ res.sendHeader(200, {'Content-Type': 'text/plain'});
+ res.sendBody('Thanks for the tip!');
+ res.finish();
} catch(e) {
res.sendHeader(500, {'Content-Type': 'text/plain'});
- res.sendBody('Problem reading post message!\n' + e.stack);
-
+ res.sendBody(e.stack);
res.finish();
- return;
}
- res.sendHeader(200, {'Content-Type': 'text/plain'});
- res.sendBody('Thanks for the tip!');
- build(body);
- res.finish();
});
}).listen(4242);
function build(data) {
p(data);
- exec("git --git-dir=data/.git --work-tree=data/ pull origin master").addCallback(function (stdout, stderr) {
+ exec("cd data && git pull origin master").addCallback(function (stdout, stderr) {
puts(stdout);
+ Build.build();
});
}
puts('Server running at http://127.0.0.1:4242/');

0 comments on commit 27b70f0

Please sign in to comment.