Skip to content

Commit ca74838

Browse files
Todd Schaveyhillin
authored andcommitted
fix #647 process argv for open-file for win and linux
1 parent 21c17dc commit ca74838

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/ElectronNET.Host/main.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@ let launchUrl;
1818

1919
let manifestJsonFileName = 'electron.manifest.json';
2020
let watchable = false;
21+
22+
// handle for opening the app with a file for win and linux
23+
if (process && process.argv.length > 1) {
24+
25+
let firstAppArgument = process.argv[1];
26+
27+
// With invoked via electronize, the first argument is the path to the main.js.
28+
// Per issue #337, the /args switch can also be present. If either are present,
29+
// we need to check the subsequent argument.
30+
if (firstAppArgument === '..\\..\\main.js' || firstAppArgument === '../../main.js' || firstAppArgument === '/args') {
31+
if (process.argv.length > 2) {
32+
firstAppArgument = process.argv[2];
33+
}
34+
}
35+
36+
// only append the first app arg if it is not already a switch
37+
if (!firstAppArgument.startsWith("--")) {
38+
app.commandLine.appendSwitch("open-file", firstAppArgument);
39+
}
40+
}
41+
2142
if (app.commandLine.hasSwitch('manifest')) {
2243
manifestJsonFileName = app.commandLine.getSwitchValue('manifest');
2344
}

0 commit comments

Comments
 (0)