File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 6
6
* the server build (and it doesn't expose a CLI option to override this).
7
7
*/
8
8
9
- import path , { join } from "path" ;
9
+ import { join , resolve } from "path" ;
10
10
import { rebuild } from "@electron/rebuild"
11
11
import { readFileSync } from "fs" ;
12
12
@@ -18,13 +18,17 @@ function getElectronVersion(distDir: string) {
18
18
const packageJsonPath = join ( distDir , "package.json" ) ;
19
19
const packageJson = JSON . parse ( readFileSync ( packageJsonPath , "utf-8" ) ) ;
20
20
21
- const electronVersion = packageJson . devDependencies . electron || packageJson . dependencies . electron ;
21
+ const electronVersion = packageJson ?. devDependencies ?. electron ?? packageJson ?. dependencies ?. electron ;
22
+ if ( ! electronVersion ) {
23
+ console . error ( `Unable to retrieve Electron version in '${ resolve ( packageJsonPath ) } '.` ) ;
24
+ process . exit ( 3 ) ;
25
+ }
22
26
23
27
return electronVersion ;
24
28
}
25
29
26
30
function main ( ) {
27
- const distDir = path . resolve ( process . argv [ 2 ] ) ;
31
+ const distDir = resolve ( process . argv [ 2 ] ) ;
28
32
if ( ! distDir ) {
29
33
console . error ( "Missing root dir as argument." ) ;
30
34
process . exit ( 1 ) ;
You can’t perform that action at this time.
0 commit comments