7
7
getFrontendVersion,
8
8
appPath,
9
9
backendPath,
10
- phZipPath,
11
10
resultsPath,
12
11
frontendReleaseUrl,
13
12
installerExePath,
@@ -80,9 +79,7 @@ const unzipBackendAndCleanUp = async (zipPath) => {
80
79
'./a11y_shell.sh' echo "Initialise"
81
80
` ;
82
81
83
- return async ( ) => {
84
- await execCommand ( unzipCommand ) ;
85
- } ;
82
+ return execCommand ( unzipCommand ) ;
86
83
} ;
87
84
88
85
const getLatestFrontendVersion = ( latestRelease , latestPreRelease ) => {
@@ -272,11 +269,11 @@ const downloadAndUnzipBackendWindows = async (tag = undefined) => {
272
269
} ) ;
273
270
} ;
274
271
275
- const downloadBackend = async ( tag = undefined ) => {
272
+ const downloadBackend = async ( tag , zipPath ) => {
276
273
const downloadUrl = `https://github.com/GovTechSG/purple-a11y/releases/download/${ tag } /purple-a11y-portable-mac.zip` ;
277
- const command = `curl '${ downloadUrl } ' -o '${ phZipPath } ' -L && rm -rf '${ backendPath } ' && mkdir '${ backendPath } '` ;
274
+ const command = `curl '${ downloadUrl } ' -o '${ zipPath } ' -L && rm -rf '${ backendPath } ' && mkdir '${ backendPath } '` ;
278
275
279
- return async ( ) => await execCommand ( command ) ;
276
+ return execCommand ( command ) ;
280
277
} ;
281
278
282
279
// MacOS only
@@ -295,11 +292,9 @@ const validateZipFile = async (zipPath) => {
295
292
return fs . existsSync ( zipPath ) && ( await isZipValid ( zipPath ) ) ;
296
293
} ;
297
294
298
- const hashAndSaveZip = ( zipPath ) => {
299
- return async ( ) => {
300
- const currHash = await hashPrepackage ( zipPath ) ;
301
- fs . writeFileSync ( hashPath , currHash ) ;
302
- } ;
295
+ const hashAndSaveZip = async ( zipPath ) => {
296
+ const currHash = await hashPrepackage ( zipPath ) ;
297
+ fs . writeFileSync ( hashPath , currHash ) ;
303
298
} ;
304
299
305
300
const run = async ( updaterEventEmitter , latestRelease , latestPreRelease ) => {
@@ -370,7 +365,6 @@ const run = async (updaterEventEmitter, latestRelease, latestPreRelease) => {
370
365
await downloadAndUnzipBackendWindows ( getFrontendVersion ( ) ) ;
371
366
}
372
367
} else {
373
- const processesToRun = [ ] ;
374
368
let restartRequired = false ;
375
369
consoleLogger . info ( "mac detected" ) ;
376
370
// user is on mac
@@ -410,32 +404,24 @@ const run = async (updaterEventEmitter, latestRelease, latestPreRelease) => {
410
404
411
405
if ( ! skipUnzip ) {
412
406
// expected to reach here when restart triggered on update
413
- processesToRun . push (
414
- ( ) => consoleLogger . info ( "proceeding to unzip backend prepackage" ) ,
415
- ( ) => updaterEventEmitter . emit ( "settingUp" ) ,
416
- await unzipBackendAndCleanUp ( macOSPrepackageBackend ) ,
417
- hashAndSaveZip ( macOSPrepackageBackend )
418
- ) ;
407
+ consoleLogger . info ( "proceeding to unzip backend prepackage" ) ;
408
+ updaterEventEmitter . emit ( "settingUp" ) ;
409
+ await unzipBackendAndCleanUp ( macOSPrepackageBackend ) ;
410
+ await hashAndSaveZip ( macOSPrepackageBackend ) ;
419
411
}
420
412
} else {
421
413
// unlikely scenario
422
- processesToRun . push (
423
- ( ) =>
424
- consoleLogger . info (
425
- "prepackage zip is invalid. proceed to download from backend. check the prepackage manually."
426
- ) ,
427
- await downloadBackend ( getFrontendVersion ( ) ) ,
428
- await unzipBackendAndCleanUp ( phZipPath ) ,
429
- hashAndSaveZip ( phZipPath )
414
+ consoleLogger . info (
415
+ "prepackage zip is invalid. proceed to download from backend."
430
416
) ;
417
+ await downloadBackend ( getFrontendVersion ( ) , macOSPrepackageBackend ) ;
418
+ await unzipBackendAndCleanUp ( macOSPrepackageBackend ) ;
419
+ await hashAndSaveZip ( macOSPrepackageBackend ) ;
431
420
}
432
421
433
422
if ( restartRequired ) {
434
- processesToRun . push ( ( ) => updaterEventEmitter . emit ( "restartTriggered" ) ) ;
435
- }
436
-
437
- for ( const proc of processesToRun ) {
438
- await proc ( ) ;
423
+ consoleLogger . info ( "restarting app..." ) ;
424
+ updaterEventEmitter . emit ( "restartTriggered" ) ;
439
425
}
440
426
}
441
427
} ;
0 commit comments