This repository was archived by the owner on May 12, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed
Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 77 var electron = require ( 'electron' )
88 var localLog = console . log
99 var localError = console . error
10- var remoteLog = electron . remote . getGlobal ( 'console' ) . log
11- var remoteError = electron . remote . getGlobal ( 'console' ) . error
10+ var remoteLog = function ( o ) {
11+ const payload = JSON . parse ( JSON . stringify ( o , null , 2 ) )
12+ electron . ipcRenderer . invoke ( 'consoleLog' , `${ payload } ` )
13+ }
14+ var remoteError = function ( o ) {
15+ const payload = JSON . parse ( JSON . stringify ( o , null , 2 ) )
16+ electron . ipcRenderer . invoke ( 'consoleError' , `${ payload } ` )
17+ }
1218
1319 console . log = function ( ...args ) {
1420 localLog . apply ( console , args )
2026 remoteError ( ...args )
2127 }
2228
23- process . exit = electron . remote . app . quit
29+ process . exit = function ( status ) { electron . ipcRenderer . sendSync ( 'exit' ) }
2430 // redirect errors to stderr
2531 window . addEventListener ( 'error' , function ( e ) {
2632 e . preventDefault ( )
27- console . error ( e . error . stack || 'Uncaught ' + e . error )
33+ console . log ( e )
34+ console . error ( e . error ?. stack || 'Uncaught ' + e . error )
2835 } )
2936 </ script >
3037 </ body >
Original file line number Diff line number Diff line change @@ -150,6 +150,10 @@ electron.app.on('ready', () => {
150150 quitting = true
151151 } )
152152
153+ electron . ipcMain . handle ( 'consoleLog' , ( ev , o ) => console . log ( o ) )
154+ electron . ipcMain . handle ( 'consoleError' , ( ev , o ) => console . error ( o ) )
155+ electron . ipcMain . on ( 'exit' , ( ev , code ) => process . exit ( code ) )
156+
153157 electron . ipcMain . on ( 'open-background-devtools' , function ( ) {
154158 if ( windows . background ) {
155159 windows . background . webContents . openDevTools ( { mode : 'detach' } )
Original file line number Diff line number Diff line change 2424 "deep-equal" : " ^2.0.1" ,
2525 "depject" : " ^4.1.1" ,
2626 "depnest" : " ^1.3.0" ,
27+ "electron-context-menu" : " ^2.5.0" ,
2728 "electron-default-menu" : " ~1.0.1" ,
2829 "electron-window-state" : " ^5.0.3" ,
2930 "escape-string-regexp" : " ^4.0.0" ,
You can’t perform that action at this time.
0 commit comments