1
- const { dialog } = require ( 'electron' ) ;
1
+ const { app , dialog } = require ( 'electron' ) ;
2
2
const exec = require ( 'child_process' ) . exec ;
3
3
const path = require ( 'path' ) ;
4
4
const fs = require ( 'fs' ) ;
@@ -13,15 +13,15 @@ const platform = process.platform;
13
13
*/
14
14
class Flasher {
15
15
static get firmwareDirectoryPath ( ) {
16
- const asarIndex = __dirname . indexOf ( ' app.asar' ) ;
16
+ const asarIndex = app . getAppPath ( ) . indexOf ( ` ${ path . sep } app.asar` ) ;
17
17
if ( asarIndex > - 1 ) {
18
- const asarPath = __dirname . substr ( 0 , asarIndex ) ;
19
- const externalFlahserPath = path . join ( asarPath , 'firmwares' ) ;
20
- const flasherPath = path . resolve ( __dirname , '..' , '..' , 'firmwares' ) ;
21
- if ( ! fs . existsSync ( externalFlahserPath ) ) {
22
- Utils . copyRecursiveSync ( flasherPath , externalFlahserPath ) ;
18
+ const asarPath = app . getAppPath ( ) . substr ( 0 , asarIndex ) ;
19
+ const externalFlasherPath = path . join ( asarPath , 'firmwares' ) ;
20
+ const flasherPath = path . resolve ( app . getAppPath ( ) , __dirname , '..' , '..' , 'firmwares' ) ;
21
+ if ( ! fs . existsSync ( externalFlasherPath ) ) {
22
+ Utils . copyRecursiveSync ( flasherPath , externalFlasherPath ) ;
23
23
}
24
- return externalFlahserPath ;
24
+ return externalFlasherPath ;
25
25
} else {
26
26
return path . resolve ( 'app' , 'firmwares' ) ;
27
27
}
0 commit comments