summaryrefslogtreecommitdiffstats
path: root/server/lib/shell.js
diff options
context:
space:
mode:
authorJannik Schönartz2019-02-28 01:26:16 +0100
committerJannik Schönartz2019-02-28 01:26:16 +0100
commitc1efc80017ec5f3d6e492749cb19c947c57fd7c0 (patch)
tree8b8d72a843d6c0ae2d87c76464e00d6bad7c9c82 /server/lib/shell.js
parent[server/ipxe] Fix codemirror only loading on click bug & add the fixes for th... (diff)
downloadbas-c1efc80017ec5f3d6e492749cb19c947c57fd7c0.tar.gz
bas-c1efc80017ec5f3d6e492749cb19c947c57fd7c0.tar.xz
bas-c1efc80017ec5f3d6e492749cb19c947c57fd7c0.zip
[webapp/ipxe] Add scroll to bottom feature, fix multiline bug and fix cancel
Diffstat (limited to 'server/lib/shell.js')
-rw-r--r--server/lib/shell.js26
1 files changed, 22 insertions, 4 deletions
diff --git a/server/lib/shell.js b/server/lib/shell.js
index 81d3008..fd5151f 100644
--- a/server/lib/shell.js
+++ b/server/lib/shell.js
@@ -31,41 +31,59 @@ module.exports = {
// Cloning git.
sendToLog(ipxeVersion, 'Cloning git ...\n', 'primary')
await cloneIpxe(ipxeVersion)
+ if (!building[ipxeVersion]) return
// Copying configs.
sendToLog(ipxeVersion, 'Copying configs ...\n', 'primary')
copyConfigs(ipxeVersion)
+ if (!building[ipxeVersion]) return
// Make ipxe.
sendToLog(ipxeVersion, 'Make iPXE ...\n', 'primary')
shell.cd(path.join(__appdir, 'ipxe', 'ipxe_' + ipxeVersion, 'src'))
await new Promise((resolve, reject) => {
+ if (!building[ipxeVersion]) return
make[ipxeVersion] = shell.exec(makeCmd, { async: true }, () => {
// make[ipxeVersion] = child.exec(makeCmd, { async: true }, () => {
- updateInProgress(ipxeVersion, false)
resolve()
})
// Send the output to the frontend log.
make[ipxeVersion].stdout.on('data', data => {
- sendToLog(ipxeVersion, data, 'normal')
+ const multiline = data.split('\n')
+ if (multiline.length > 2) {
+ multiline.forEach(line => {
+ if (line) sendToLog(ipxeVersion, line, 'normal')
+ })
+ } else sendToLog(ipxeVersion, data, 'normal')
})
make[ipxeVersion].stderr.on('data', data => {
- sendToLog(ipxeVersion, data, 'error')
+ const multiline = data.split('\n')
+ if (multiline.length > 2) {
+ multiline.forEach(line => {
+ if (line) sendToLog(ipxeVersion, line, 'error')
+ })
+ } else sendToLog(ipxeVersion, data, 'error')
})
})
+ if (!building[ipxeVersion]) return
// Copy and rename the ipxe file.
+ sendToLog(ipxeVersion, 'Copying ipxe file ...\n', 'primary')
shell.cp('bin/undionly.kpxe', path.join(__appdir, 'ipxe'))
shell.mv(path.join(__appdir, 'ipxe', 'undionly.kpxe'), path.join(__appdir, 'ipxe', 'ipxe.' + ipxeVersion))
+ sendToLog(ipxeVersion, 'done\n', 'success')
+ updateInProgress(ipxeVersion, false)
},
cancelBuilding: async function (req, res) {
- const process = make[req.params.version]
+ const ipxeVersion = req.params.version
+ const process = make[ipxeVersion]
if (process) {
const kill = 'pkill -P ' + process.pid
shell.exec(kill)
+ updateInProgress(ipxeVersion, false)
}
res.send({ status: 'SUCCESS', data: process })
},