chore: remove app.makeSingleInstance / releaseSingleInstance (#14518)
This commit is contained in:
parent
f012ed8357
commit
dcd580b6cf
4 changed files with 0 additions and 55 deletions
|
@ -107,21 +107,6 @@ for (let name of events) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(MarshallOfSound): Remove in 4.0
|
|
||||||
app.releaseSingleInstance = () => {
|
|
||||||
deprecate.warn('app.releaseSingleInstance(cb)', 'app.releaseSingleInstanceLock()')
|
|
||||||
app.releaseSingleInstanceLock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(MarshallOfSound): Remove in 4.0
|
|
||||||
app.makeSingleInstance = (oldStyleFn) => {
|
|
||||||
deprecate.warn('app.makeSingleInstance(cb)', 'app.requestSingleInstanceLock() and app.on(\'second-instance\', cb)')
|
|
||||||
if (oldStyleFn && typeof oldStyleFn === 'function') {
|
|
||||||
app.on('second-instance', (event, ...args) => oldStyleFn(...args))
|
|
||||||
}
|
|
||||||
return !app.requestSingleInstanceLock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wrappers for native classes.
|
// Wrappers for native classes.
|
||||||
const {DownloadItem} = process.atomBinding('download_item')
|
const {DownloadItem} = process.atomBinding('download_item')
|
||||||
Object.setPrototypeOf(DownloadItem.prototype, EventEmitter.prototype)
|
Object.setPrototypeOf(DownloadItem.prototype, EventEmitter.prototype)
|
||||||
|
|
|
@ -202,28 +202,6 @@ 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 => {
|
|
||||||
expect(code).to.equal(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 => {
|
|
||||||
expect(code).to.equal(1)
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('app.requestSingleInstanceLock', () => {
|
describe('app.requestSingleInstanceLock', () => {
|
||||||
it('prevents the second launch of app', function (done) {
|
it('prevents the second launch of app', function (done) {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
|
|
13
spec/fixtures/api/singleton-old/main.js
vendored
13
spec/fixtures/api/singleton-old/main.js
vendored
|
@ -1,13 +0,0 @@
|
||||||
const {app} = require('electron')
|
|
||||||
|
|
||||||
app.once('ready', () => {
|
|
||||||
console.log('started') // ping parent
|
|
||||||
})
|
|
||||||
|
|
||||||
const shouldExit = app.makeSingleInstance(() => {
|
|
||||||
setImmediate(() => app.exit(0))
|
|
||||||
})
|
|
||||||
|
|
||||||
if (shouldExit) {
|
|
||||||
app.exit(1)
|
|
||||||
}
|
|
5
spec/fixtures/api/singleton-old/package.json
vendored
5
spec/fixtures/api/singleton-old/package.json
vendored
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"name": "electron-app-singleton",
|
|
||||||
"main": "main.js"
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue