11// @ts -nocheck
2- // Basic init
32const { app, BrowserWindow, ipcMain, Menu, Dialog } = require ( 'electron' ) ;
43const createMenuBar = require ( './backend/menuBar.js' ) ;
54const { fork, exec } = require ( 'child_process' ) ;
65const path = require ( 'path' ) ;
76const fs = require ( 'fs' ) ;
87
9- // To avoid being garbage collected
108let mainWindow ;
119
1210app . on ( 'ready' , ( ) => {
@@ -15,34 +13,36 @@ app.on('ready', () => {
1513 //Adding Menu Bar
1614 const menu = Menu . buildFromTemplate ( createMenuBar ( mainWindow , ResetDir , OpenDir ) ) ;
1715 Menu . setApplicationMenu ( menu ) ;
18- const initialStartFlagFilePath = path . join ( __dirname , 'electronUserData' , 'initialStartup.txt' ) ;
19- if ( ! fs . existsSync ( initialStartFlagFilePath ) ) {
20- let pathToExecutable ;
21- if ( process . platform === 'darwin' ) {
22- pathToExecutable = path . join ( __dirname , '..' , '..' , 'MacOS' , 'bundle-bee' ) ;
23- } else if ( process . platform === 'win32' ) {
24- pathToExecutable = path . join ( __dirname , '..' , '..' , 'MacOS' , 'bundle-bee' ) ;
25- }
26- fs . writeFile (
27- initialStartFlagFilePath ,
28- `command to run executable:
16+ if ( process . env . NODE_ENV === 'packaging' ) {
17+ const initialStartFlagFilePath = path . join ( __dirname , 'electronUserData' , 'initialStartup.txt' ) ;
18+ if ( ! fs . existsSync ( initialStartFlagFilePath ) ) {
19+ let pathToExecutable ;
20+ if ( process . platform === 'darwin' ) {
21+ pathToExecutable = path . join ( __dirname , '..' , '..' , 'MacOS' , 'bundle-bee' ) ;
22+ } else if ( process . platform === 'win32' ) {
23+ pathToExecutable = path . join ( __dirname , '..' , '..' , 'MacOS' , 'bundle-bee' ) ;
24+ }
25+ fs . writeFile (
26+ initialStartFlagFilePath ,
27+ `command to run executable:
2928 open ${ pathToExecutable }
3029 dirname: ${ __dirname }
3130 filename: ${ __filename }
3231 initalstartflagfilepath: ${ initialStartFlagFilePath }
3332 `
34- ) ;
35- exec ( `open ${ pathToExecutable } ` , err => {
33+ ) ;
34+ exec ( `open ${ pathToExecutable } ` , err => {
35+ app . exit ( 0 ) ;
36+ } ) ;
37+ } else {
38+ fs . unlink ( initialStartFlagFilePath , err => {
39+ if ( err ) console . log ( err ) ;
40+ } ) ;
41+ }
42+ mainWindow . on ( 'close' , ( ) => {
3643 app . exit ( 0 ) ;
3744 } ) ;
38- } else {
39- fs . unlink ( initialStartFlagFilePath , err => {
40- if ( err ) console . log ( err ) ;
41- } ) ;
4245 }
43- mainWindow . on ( 'close' , ( ) => {
44- app . exit ( 0 ) ;
45- } ) ;
4646} ) ;
4747
4848ipcMain . on ( 'ondragstart' , ( event , filePath ) => {
@@ -178,4 +178,4 @@ function ResetDir() {
178178 app . exit ( 0 ) ;
179179}
180180
181- function OpenDir ( build ) { }
181+ function OpenDir ( build ) { }
0 commit comments