Commit bd5582f7 authored by zhiyan's avatar zhiyan

更新wiki hook脚本

parent feb2ac04
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
const express = require('express') const express = require('express')
const bodyParser = require('body-parser') const bodyParser = require('body-parser')
const low = require('lowdb') const low = require('lowdb')
const exec = require('exec')
const db = low('./usage.json') const db = low('./usage.json')
const app = express() const app = express()
...@@ -22,6 +23,25 @@ app.get('/usage', function (req, res) { ...@@ -22,6 +23,25 @@ app.get('/usage', function (req, res) {
}) })
}) })
app.get('/book/update', function(req, res){
const WIKI_PATH = '/home/wiki'
const commands = [
'cd ' + WIKI_PATH,
'git pull'
].join('&&')
exec(commands, function(err,out){
if(err instanceof Error){
res.writeHead(500)
res.end('Hook error')
throw err
}
process.stderr.write(err)
process.stdout.write(out)
res.writeHead(200)
})
})
app.post('/register', function(req, res){ app.post('/register', function(req, res){
const machine = req.body.machine const machine = req.body.machine
const branch = req.body.branch const branch = req.body.branch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment