Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit c0286c8

Browse files
committed
Load the nativephp configuration before doing anything else.
This allows us to call code before actually starting the Electron app.
1 parent 08550aa commit c0286c8

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/index.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ class NativePHP {
7575
}
7676

7777
private bootstrapApp(app: Electron.CrossProcessExports.App) {
78+
let nativePHPConfig = {};
79+
80+
// Wait for promise to resolve
81+
retrieveNativePHPConfig().then((result) => {
82+
try {
83+
nativePHPConfig = JSON.parse(result.stdout);
84+
} catch (e) {
85+
console.error(e);
86+
}
87+
}).catch((err) => {
88+
console.error(err);
89+
}).finally(() => {
90+
this.setupApp(nativePHPConfig);
91+
});
92+
}
93+
94+
private setupApp(nativePHPConfig: any) {
7895
app.whenReady().then(async () => {
7996

8097
// Only run this on macOS
@@ -89,17 +106,9 @@ class NativePHP {
89106
optimizer.watchWindowShortcuts(window)
90107
})
91108

92-
let nativePHPConfig = {};
93-
try {
94-
let {stdout} = await retrieveNativePHPConfig()
95-
nativePHPConfig = JSON.parse(stdout);
96-
} catch (e) {
97-
console.error(e);
98-
}
99-
100109
let phpIniSettings = {};
101110
try {
102-
let {stdout} = await retrievePhpIniSettings()
111+
let { stdout } = await retrievePhpIniSettings()
103112
phpIniSettings = JSON.parse(stdout);
104113
} catch (e) {
105114
console.error(e);
@@ -145,15 +154,15 @@ class NativePHP {
145154
}, 60 * 1000);
146155
}, delay);
147156

148-
app.on('activate', function (event, hasVisibleWindows) {
157+
app.on('activate', function(event, hasVisibleWindows) {
149158
// On macOS it's common to re-create a window in the app when the
150159
// dock icon is clicked and there are no other windows open.
151160
if (!hasVisibleWindows) {
152161
notifyLaravel('booted')
153162
}
154163
event.preventDefault();
155164
})
156-
})
165+
});
157166
}
158167
}
159168

0 commit comments

Comments
 (0)