@@ -35,6 +35,8 @@ function createWindow() {
35
35
// Add event listener to set our global window variable to null
36
36
// This is needed so that window is able to reopen when user relaunches the app
37
37
win . on ( 'closed' , ( ) => {
38
+ //added to overwrite .env with null every time window is closed so new import can work
39
+ fs . writeFileSync ( path . join ( __dirname , '/.env' ) , "" , 'utf8' ) ;
38
40
win = null ;
39
41
} ) ;
40
42
@@ -209,14 +211,14 @@ ipcMain.on('import-tables', (event, env) => {
209
211
let tables ;
210
212
pgQuery ( tables )
211
213
. then ( ( tables ) => {
212
- console . log ( "tables (main):" , tables )
214
+ // console.log("tables (main):", tables)
213
215
event . reply ( 'tables-imported' , tables )
214
216
} )
215
217
. catch ( err => console . error ( "Error importing tables from postgres" ) )
216
218
} )
217
219
//--------------------- CREATE ENV FILE -------------------//
218
220
219
- function createEnvFile ( env ) {
221
+ async function createEnvFile ( env ) {
220
222
try {
221
223
fs . writeFileSync ( path . join ( __dirname , '/.env' ) , env , 'utf8' )
222
224
} catch ( err ) {
@@ -225,8 +227,15 @@ function createEnvFile(env) {
225
227
}
226
228
227
229
ipcMain . on ( 'create-env-file' , ( event , env ) => {
228
- console . log ( env ) ;
229
- createEnvFile ( env ) ;
230
+ console . log ( 'create env file URI: ' , env ) ;
231
+ createEnvFile ( env )
232
+ . then ( res => {
233
+ event . reply ( 'env-file-created' ) ;
234
+ console . log ( 'env-file-created' )
235
+ } )
236
+ . catch ( err => {
237
+ console . log ( 'error occurred in createEnvFile promise' )
238
+ } )
230
239
} ) ;
231
240
232
241
//--------------------- MENU CUSTOMIZATION -------------------//
0 commit comments