This repository was archived by the owner on May 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdates.js
More file actions
29 lines (28 loc) · 1.3 KB
/
updates.js
File metadata and controls
29 lines (28 loc) · 1.3 KB
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
var childprocess = require('child_process')
exports.updateSocket = function (io) {
return function (req, res, next) {
io.on('connection', function (socket) {
socket.on('start', function (data) {
if (req.session['isAdmin']) {
socket.emit('log', { message: req.localize('updating serpentes') })
var process = childprocess.spawn('git' , ['pull', 'origin', 'feature/master'])
process.stdout.on('data', function (data) {
console.log(data.toString())
socket.emit('log', { message: data.toString('UTF-8') });
})
process.stderr.on('data', function (data) {
console.log(data.toString())
socket.emit('log', { message: data.toString('UTF-8') });
})
process.on('exit', function (code, signal) {
console.log('exited with code ' + code)
socket.emit('log', { message: 'exit with code ' + code })
process.kill()
})
} else {
socket.emit('log', req.localize('only admins can update'))
}
})
})
}
}