65ee977a86
* Fix timing issue in singleton fixture. Singleton now sends the "we've started" message out only after it's received a `'ready'` event from `app`. Previously it sent the message out immediately, resulting in the parent test trying to manipulate it before Singleton's event loop was fully bootstrapped. * Check for graceful exits on Linux, too. Rewrite the "exits gracefully on macos" spec to run on Linux too. * Check for graceful exits everywhere. * Tweak comment * Better error logging in api-app-spec.js. (#12122) In the 'exits gracefully' test for app.exit(exitCode), print the relevant error information if the test fails. * Run the exit-gracefully test on macOS and Linux. Windows does not support sending signals, but Node.js offers some emulation with process.kill(), and subprocess.kill(). Sending signal 0 can be used to test for the existence of a process. Sending SIGINT, SIGTERM, and SIGKILL cause the unconditional termination of the target process. So, we'll need a different approach if we want to test this in win32.
13 lines
232 B
JavaScript
13 lines
232 B
JavaScript
const {app} = require('electron')
|
|
|
|
app.once('ready', () => {
|
|
console.log('started') // ping parent
|
|
})
|
|
|
|
const shouldExit = app.makeSingleInstance(() => {
|
|
process.nextTick(() => app.exit(0))
|
|
})
|
|
|
|
if (shouldExit) {
|
|
app.exit(1)
|
|
}
|