fix #647 process argv for open-file for win and linux

This commit is contained in:
Todd Schavey
2021-12-28 21:40:53 -05:00
committed by lucas
parent 21c17dc82b
commit ca748384cf

View File

@@ -18,6 +18,27 @@ let launchUrl;
let manifestJsonFileName = 'electron.manifest.json';
let watchable = false;
// handle for opening the app with a file for win and linux
if (process && process.argv.length > 1) {
let firstAppArgument = process.argv[1];
// With invoked via electronize, the first argument is the path to the main.js.
// Per issue #337, the /args switch can also be present. If either are present,
// we need to check the subsequent argument.
if (firstAppArgument === '..\\..\\main.js' || firstAppArgument === '../../main.js' || firstAppArgument === '/args') {
if (process.argv.length > 2) {
firstAppArgument = process.argv[2];
}
}
// only append the first app arg if it is not already a switch
if (!firstAppArgument.startsWith("--")) {
app.commandLine.appendSwitch("open-file", firstAppArgument);
}
}
if (app.commandLine.hasSwitch('manifest')) {
manifestJsonFileName = app.commandLine.getSwitchValue('manifest');
}