This commit is contained in:
2019-06-07 23:04:57 +08:00
commit 36b92f19e0
67 changed files with 18266 additions and 0 deletions

25
src/websocket/log.js Normal file
View File

@ -0,0 +1,25 @@
import fs from 'fs'
import db from '../lib/db'
export default (io, socket, docker) => {
socket.on('log', function (path) {
path = decodeURI(path)
const logLast = db.get('buildLog')
.filter({logPath: path})
.sortBy((item) => -item.startDate)
.take()
.first()
.value()
if (logLast && logLast.logPath) {
try {
socket.emit('show', fs.readFileSync(logLast.logPath) + '\n')
} catch (err) {
socket.emit('show', err.toString() + '\n')
}
} else {
socket.emit('show', 'No file.')
}
})
}