-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (30 loc) · 951 Bytes
/
server.js
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
28
29
30
31
32
33
34
35
const http = require('http')
const path = require('path')
const { exec } = require('child_process')
const bodyParser = require('body-parser')
const express = require('express')
const ecstatic = require('ecstatic')
const history = require('connect-history-api-fallback')
const app = express()
app.use(bodyParser.json())
app.post('//update', (req, res) => {
console.log('pull start')
res.send('ok')
exec('git pull https://[email protected]/apulis/NewObjectLabel.git', (err, result) => {
if (!err) {
console.log('pull over')
exec('yarn build', (err, result) => {
if (!err) {
console.log('build over')
} else {
console.log('build err', err)
}
})
} else {
console.log('pull error', err)
}
})
})
app.use(history())
app.use(ecstatic({ root: path.join(__dirname, './dist') }))
http.createServer(app).listen(process.argv[2] || 3085)