mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: second-instance additionalData parameter (#31661)
* test: second-instance additionalData parameter * Fix posix implementation
This commit is contained in:
15
spec/fixtures/api/singleton-data/main.js
vendored
15
spec/fixtures/api/singleton-data/main.js
vendored
@@ -1,10 +1,13 @@
|
||||
const { app } = require('electron');
|
||||
|
||||
// Send data from the second instance to the first instance.
|
||||
const sendAdditionalData = app.commandLine.hasSwitch('send-data');
|
||||
|
||||
app.whenReady().then(() => {
|
||||
console.log('started'); // ping parent
|
||||
});
|
||||
|
||||
const obj = {
|
||||
let obj = {
|
||||
level: 1,
|
||||
testkey: 'testvalue1',
|
||||
inner: {
|
||||
@@ -12,7 +15,15 @@ const obj = {
|
||||
testkey: 'testvalue2'
|
||||
}
|
||||
};
|
||||
const gotTheLock = app.requestSingleInstanceLock(obj);
|
||||
if (app.commandLine.hasSwitch('data-content')) {
|
||||
obj = JSON.parse(app.commandLine.getSwitchValue('data-content'));
|
||||
if (obj === 'undefined') {
|
||||
obj = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const gotTheLock = sendAdditionalData
|
||||
? app.requestSingleInstanceLock(obj) : app.requestSingleInstanceLock();
|
||||
|
||||
app.on('second-instance', (event, args, workingDirectory, data) => {
|
||||
setImmediate(() => {
|
||||
|
||||
4
spec/fixtures/api/singleton/main.js
vendored
4
spec/fixtures/api/singleton/main.js
vendored
@@ -6,9 +6,9 @@ app.whenReady().then(() => {
|
||||
|
||||
const gotTheLock = app.requestSingleInstanceLock();
|
||||
|
||||
app.on('second-instance', (event, args, workingDirectory, data) => {
|
||||
app.on('second-instance', (event, args, workingDirectory) => {
|
||||
setImmediate(() => {
|
||||
console.log([JSON.stringify(args), JSON.stringify(data)].join('||'));
|
||||
console.log(JSON.stringify(args));
|
||||
app.exit(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user