@@ -67,11 +67,6 @@ interface CommandLineOptions
6767PhpCommand . binary = join ( resourceDir , 'bin' , process . platform === 'win32' ? 'php.exe' : 'php' ) ;
6868
6969ipcMain . handle ( 'drupal:start' , async ( { sender : win } ) : Promise < string | null > => {
70- // Set up logging to help with debugging auto-update problems, and ensure any
71- // errors are sent to Sentry.
72- autoUpdater . logger = logger ;
73- autoUpdater . on ( 'error' , e => Sentry . captureException ( e ) ) ;
74-
7570 // Open a channel to the renderer so we can send progress information in real time.
7671 const {
7772 port1 : progress ,
@@ -111,9 +106,10 @@ ipcMain.handle('drupal:start', async ({ sender: win }): Promise<string | null> =
111106 if ( 'CI' in process . env ) {
112107 app . quit ( ) ;
113108 }
114- // On newer versions of macOS, the app cannot be auto-updated if it's not in
115- // the Applications folder, and will cause an error. In that situation, don't
116- // even bother to check for updates.
109+ // We wait until Drupal is up and running before checking for updates because we
110+ // don't want to interrupt Drupal's spin-up process. On newer versions of macOS,
111+ // the app cannot be auto-updated if it's not in the Applications folder, and will
112+ // cause an error. In that situation, skip the update check.
117113 else if ( process . platform === 'darwin' && ! app . isInApplicationsFolder ( ) ) {
118114 logger . debug ( 'macOS: Skipping update check because app is not in the Applications folder.' ) ;
119115 }
@@ -188,50 +184,8 @@ ipcMain.handle('drupal:destroy', async (): Promise<void> => {
188184// But for a pure launcher like this one, it makes more sense to just quit.
189185app . on ( 'window-all-closed' , app . quit ) ;
190186
191- function createWindow ( ) : void
192- {
193- const win = new BrowserWindow ( {
194- width : 800 ,
195- height : 500 ,
196- webPreferences : {
197- preload : join ( __dirname , '..' , 'preload' , 'preload.js' ) ,
198- } ,
199- } ) ;
200-
201- // If running in development, leave the menu as-is so we can access dev tools.
202- if ( app . isPackaged ) {
203- // On macOS, totally redefine the menu.
204- if ( process . platform === 'darwin' ) {
205- const menu : Menu = Menu . buildFromTemplate ( [
206- {
207- label : app . getName ( ) ,
208- submenu : [
209- {
210- label : i18next . t ( 'menu.about' ) ,
211- role : 'about' ,
212- } ,
213- {
214- label : i18next . t ( 'menu.quit' ) ,
215- accelerator : 'Command+Q' ,
216- click ( ) {
217- app . quit ( ) ;
218- } ,
219- } ,
220- ] ,
221- }
222- ] ) ;
223- Menu . setApplicationMenu ( menu ) ;
224- }
225- else {
226- // Disable the default menu on Windows and Linux, since it doesn't make sense
227- // for this app.
228- Menu . setApplicationMenu ( null ) ;
229- }
230- }
231- win . loadFile ( join ( __dirname , '..' , 'renderer' , 'index.html' ) ) ;
232- }
233-
234187app . whenReady ( ) . then ( async ( ) : Promise < void > => {
188+ // Set up internationalization.
235189 await i18next . init ( {
236190 resources : {
237191 en : {
@@ -316,11 +270,52 @@ app.whenReady().then(async (): Promise<void> => {
316270 // a function, but that's just how electron-log works.
317271 logger . transports . file . resolvePathFn = ( ) : string => argv . log ;
318272
273+ // Ensure any auto-update errors are logged and send to Sentry.
274+ autoUpdater . logger = logger ;
275+ autoUpdater . on ( 'error' , e => Sentry . captureException ( e ) ) ;
276+
277+ // If running in development, leave the menu as-is so we can access dev tools.
278+ if ( app . isPackaged ) {
279+ // The default menu doesn't make sense for this app.
280+ Menu . setApplicationMenu ( null ) ;
281+
282+ // On macOS, create a minimalistic menu.
283+ if ( process . platform === 'darwin' ) {
284+ const menu : Menu = Menu . buildFromTemplate ( [
285+ {
286+ label : app . getName ( ) ,
287+ submenu : [
288+ {
289+ label : i18next . t ( 'menu.about' ) ,
290+ role : 'about' ,
291+ } ,
292+ {
293+ label : i18next . t ( 'menu.quit' ) ,
294+ accelerator : 'Command+Q' ,
295+ click ( ) {
296+ app . quit ( ) ;
297+ } ,
298+ } ,
299+ ] ,
300+ }
301+ ] ) ;
302+ Menu . setApplicationMenu ( menu ) ;
303+ }
304+ }
305+
319306 // Initialize the object that manages the Drupal site.
320307 drupal = new Drupal (
321308 argv . root ,
322309 argv . fixture ? join ( __dirname , '..' , '..' , 'tests' , 'fixtures' , argv . fixture ) : null ,
323310 ) ;
324311
325- createWindow ( ) ;
312+ // We're all set; load the UI.
313+ const win = new BrowserWindow ( {
314+ width : 800 ,
315+ height : 500 ,
316+ webPreferences : {
317+ preload : join ( __dirname , '..' , 'preload' , 'preload.js' ) ,
318+ } ,
319+ } ) ;
320+ win . loadFile ( join ( __dirname , '..' , 'renderer' , 'index.html' ) ) ;
326321} ) ;
0 commit comments