-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (23 loc) · 660 Bytes
/
app.js
File metadata and controls
27 lines (23 loc) · 660 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var path = require('path');
var express = require('express');
var config = require('./config');
var exec = require('child_process').exec;
var app = express();
config.webhooks.forEach(function(item) {
app.post(item.route, function(req, res) {
var cmd = 'cd ' + item.path + ' && git pull';
exec(cmd, function(err, stdout) {
if (err) {
console.error(err);
res.status(500).end();
} else {
console.log(item.path + ' pull success! ');
console.log(stdout);
res.status(200).end();
}
});
});
});
app.listen(config.port, function() {
console.log('webhook listening on %d', config.port);
});