Skip to content

Commit afcd113

Browse files
singleInstance handle command line arguments
1 parent 0e22ee3 commit afcd113

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ElectronNET.API:
1616
* Breaking API Changes (from native Electron 13.1.5):
1717
- `Shell.MoveItemToTrashAsync` renamed with `Shell.TrashItemAsync`
1818
- The deprecated extension APIs have been removed: `BrowserWindow.GetAllExtensionsAsync()`, `BrowserWindow.RemoveExtension()`, `BrowserWindow.AddExtensionAsync()`. Use the session APIs instead: `Session.GetAllExtensionsAsync()`, `Session.RemoveExtension()`, `Session.LoadExtensionAsync()`.
19+
* New Feature: singleInstance handle command line arguments [\#520](https://github.com/ElectronNET/Electron.NET/issues/520)
1920
* New Feature: Add WebContents [insertCSS](https://www.electronjs.org/docs/api/web-contents#contentsinsertcsscss-options) functionality (thanks [nfichter](https://github.com/nfichter)) [\#559](https://github.com/ElectronNET/Electron.NET/pull/559)
2021
* New Feature: Allow IpcMain to send IPC messages to BrowserViews (thanks [nfichter](https://github.com/nfichter)) [\#560](https://github.com/ElectronNET/Electron.NET/pull/560)
2122
* New Feature: Add support for proxies that require basic username/password authentication (thanks [nfichter](https://github.com/nfichter)) [\#561](https://github.com/ElectronNET/Electron.NET/pull/561)

ElectronNET.Host/main.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ app.on('will-finish-launching', () => {
5050
const manifestJsonFile = require(manifestJsonFilePath);
5151
if (manifestJsonFile.singleInstance || manifestJsonFile.aspCoreBackendPort) {
5252
const mainInstance = app.requestSingleInstanceLock();
53-
app.on('second-instance', () => {
53+
app.on('second-instance', (events, args = []) => {
54+
args.forEach(parameter => {
55+
const words = parameter.split('=');
56+
57+
if(words.length > 1) {
58+
app.commandLine.appendSwitch(words[0].replace('--', ''), words[1]);
59+
} else {
60+
app.commandLine.appendSwitch(words[0].replace('--', ''));
61+
}
62+
});
63+
5464
const windows = BrowserWindow.getAllWindows();
5565
if (windows.length) {
5666
if (windows[0].isMinimized()) {

0 commit comments

Comments
 (0)