Skip to content
This repository was archived by the owner on Jan 14, 2022. It is now read-only.

Commit 0e9fc47

Browse files
authored
accept auto open BIM as first cmd line arg (#26)
1 parent c363abe commit 0e9fc47

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

.vscode/launch.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
},
2929
"windows": {
3030
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
31-
}
31+
},
32+
"args": [
33+
// "C:\\Temp\\t1\\a.bim"
34+
]
3235
},
3336
{
3437
"name": "Renderer",

src/frontend/components/AppComponent.tsx

+13-4
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,19 @@ export default class AppComponent extends React.Component<{}, AppState> {
8282
}
8383

8484
private initializeAutoOpen() {
85-
// If a snapshot is configured in .env.local, then use for auto-opening at startup
86-
try {
87-
this.snapshotName = Config.App.get("imjs_offline_imodel");
88-
} catch (e) { }
85+
// First, check the command line.
86+
let argv = (this.getRemote().process.argv as string[]).slice(1); // trim leading EXE name
87+
if (this.getRemote().process.env.NODE_ENV === "development") // dev launches electron EXE with its own runtime args, need to skip them
88+
argv = argv.slice(1 + argv.findIndex((a) => a.includes("main.js")));
89+
if (argv.length > 0)
90+
this.snapshotName = argv[0];
91+
92+
// Then try app configraiton (e.g. .env.local)
93+
if (!this.snapshotName) {
94+
try {
95+
this.snapshotName = Config.App.get("imjs_offline_imodel");
96+
} catch (e) { }
97+
}
8998

9099
// If no snapshot, check if a project/iModel is configured
91100
if (!this.snapshotName) {

0 commit comments

Comments
 (0)