feat: new makeSingleInstance API (#12782)
* Refactor app.makeSingleInstance * new API `app.isPrimaryInstance()` * new API `app.isSingleInstance()` * new event `app.on('second-instance')` * deprecated old syntax `app.makeSingleInstance(cb)` * deprecated old syntax of `app.makeSingleInstance() --> bool` in favor of `app.isPrimaryInstance()` * Fix spec, we don't need process.nextTick hacks any more * Make deprecation TODO for the return value of makeSingleInstance * Refactor makeSingleInstance to requestSingleInstanceLock and add appropriate deprecation comments * I swear this isn't tricking the linter * Make const * Add deprecation warnings for release, and add to planned-breaking-changes BREAKING CHANGE
This commit is contained in:
parent
9c8952aef0
commit
5b5c161601
9 changed files with 176 additions and 52 deletions
|
@ -185,7 +185,29 @@ describe('app module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
// TODO(MarshallOfSound) - Remove in 4.0.0
|
||||
describe('app.makeSingleInstance', () => {
|
||||
it('prevents the second launch of app', function (done) {
|
||||
this.timeout(120000)
|
||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'singleton-old')
|
||||
// First launch should exit with 0.
|
||||
const first = ChildProcess.spawn(remote.process.execPath, [appPath])
|
||||
first.once('exit', (code) => {
|
||||
assert.equal(code, 0)
|
||||
})
|
||||
// Start second app when received output.
|
||||
first.stdout.once('data', () => {
|
||||
// Second launch should exit with 1.
|
||||
const second = ChildProcess.spawn(remote.process.execPath, [appPath])
|
||||
second.once('exit', (code) => {
|
||||
assert.equal(code, 1)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('app.requestSingleInstanceLock', () => {
|
||||
it('prevents the second launch of app', function (done) {
|
||||
this.timeout(120000)
|
||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'singleton')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue