Fix argv.length check in makeSingleInstance callback

Also correct length of argv: with Electron, there's just the
executable, not interpreter + filename.
This commit is contained in:
Alex Liebowitz 2017-05-10 21:27:57 -04:00
parent 856aa28db2
commit 2b6528ca3e

View file

@ -178,19 +178,19 @@ function quitNow() {
} }
const isSecondaryInstance = app.makeSingleInstance((argv) => { const isSecondaryInstance = app.makeSingleInstance((argv) => {
if (process.argv.length < 3) { if (argv.length < 2) {
return; return;
} }
if (!win) { if (!win) {
openUri = argv[2]; openUri = argv[1];
} else { } else {
if (win.isMinimized()) { if (win.isMinimized()) {
win.restore(); win.restore();
win.focus(); win.focus();
} }
win.webContents.send('open-uri-requested', argv[2]); win.webContents.send('open-uri-requested', argv[1]);
} }
}); });
@ -347,11 +347,11 @@ if (process.platform == 'darwin') {
win.webContents.send('open-uri-requested', uri); win.webContents.send('open-uri-requested', uri);
} }
}); });
} else if (process.argv.length >= 3) { } else if (process.argv.length >= 2) {
// No open-url event on Win, but we can still handle URIs provided at launch time // No open-url event on Win, but we can still handle URIs provided at launch time
if (!win) { if (!win) {
openUri = process.argv[2]; openUri = process.argv[1];
} else { } else {
win.webContents.send('open-uri-requested', process.argv[2]); win.webContents.send('open-uri-requested', process.argv[1]);
} }
} }