launcher: add a console that prints stderr and stdout
This commit is contained in:
parent
28b1fc2d4f
commit
9e0ad98955
5 changed files with 84 additions and 10 deletions
|
|
@ -167,20 +167,32 @@ $(document).ready(()=>{
|
|||
|
||||
})
|
||||
|
||||
form.appendTo('#launcher')
|
||||
|
||||
|
||||
// server started callback
|
||||
ipcRenderer.on('started',function(){
|
||||
var addresses = settings.read('appAddresses').map((a)=>{return `<a href="${a}">${a}</a>`})
|
||||
start.addClass('started').html('App available at ' + addresses.join(' & '))
|
||||
start.remove()
|
||||
save.remove()
|
||||
terminal.show()
|
||||
})
|
||||
|
||||
// Fake console
|
||||
var terminal = $(`<div class="terminal"></div>`).appendTo('#launcher').hide()
|
||||
|
||||
ipcRenderer.on('stdout', function(e, msg){
|
||||
terminal.append(`<div class="log">${msg}</div>`)
|
||||
terminal.scrollTop(terminal.prop('scrollHeight'))
|
||||
})
|
||||
|
||||
ipcRenderer.on('stderr', function(e, msg){
|
||||
terminal.append(`<div class="error">${msg}</div>`)
|
||||
terminal.scrollTop(terminal.prop('scrollHeight'))
|
||||
})
|
||||
|
||||
|
||||
// ready
|
||||
|
||||
form.appendTo('#launcher')
|
||||
|
||||
$('input').trigger('change')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,24 @@ if (settings.cli) {
|
|||
launcher
|
||||
|
||||
app.on('ready',function(){
|
||||
launcher = require('./electron-window')({address:address, shortcuts:false, width:680, height:568, color:'#283143'})
|
||||
launcher = require('./electron-window')({address:address, shortcuts:true, width:680, height:568, color:'#283143'})
|
||||
})
|
||||
|
||||
process.stdout.write = (function(write) {
|
||||
return function(string, encoding, fd) {
|
||||
write.apply(process.stdout, arguments)
|
||||
launcher.webContents.send('stdout', string)
|
||||
}
|
||||
})(process.stdout.write)
|
||||
|
||||
process.stderr.write = (function(write) {
|
||||
return function(string, encoding, fd) {
|
||||
write.apply(process.stdout, arguments)
|
||||
launcher.webContents.send('stderr', string)
|
||||
}
|
||||
})(process.stderr.write)
|
||||
|
||||
|
||||
ipcMain.on('start',function(e, options){
|
||||
|
||||
var gui = start()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue