@@ -23,9 +23,40 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
23
23
// See: https://github.com/electron-userland/electron-builder/issues/2468
24
24
// Regression in Theia: https://github.com/eclipse-theia/theia/issues/8701
25
25
app . on ( 'ready' , ( ) => app . setName ( config . applicationName ) ) ;
26
+
27
+ // Add file associations to the app
28
+ this . attachFileAssociations ( ) ;
29
+
26
30
return super . start ( config ) ;
27
31
}
28
32
33
+ attachFileAssociations ( ) {
34
+
35
+ // OSX: register open-file event
36
+ if ( process . platform === 'darwin' ) {
37
+ app . on ( 'open-file' , ( event , uri ) => {
38
+ event . preventDefault ( ) ;
39
+ // TODO: check if the URI is a .ino file
40
+ // should I call openSketchFiles(uri) ?
41
+ } ) ;
42
+ }
43
+
44
+ // WIN: read file(s) uri from executable args
45
+ if ( process . platform === 'win32' ) {
46
+ if ( app . isPackaged ) {
47
+ // workaround for missing executable argument when app is packaged
48
+ process . argv . unshift ( 'packaged' ) ;
49
+ }
50
+ // parameters is an array containing any files/folders that your OS will pass to your application
51
+ const uri = process . argv . slice ( 2 ) || null ;
52
+ if ( uri ) {
53
+ // TODO: filter out only the first .ino file in the array
54
+ // should I call openSketchFiles(uri) ?
55
+ }
56
+ }
57
+
58
+ }
59
+
29
60
/**
30
61
* Use this rather than creating `BrowserWindow` instances from scratch, since some security parameters need to be set, this method will do it.
31
62
*
0 commit comments