3
3
import { InvalidConfigurationError , log } from "builder-util"
4
4
import * as chalk from "chalk"
5
5
import { getElectronVersion } from "app-builder-lib/out/electron/electronVersion"
6
- import { pathExists , readJson } from "fs-extra"
6
+ import { readJson } from "fs-extra"
7
7
import * as isCi from "is-ci"
8
8
import * as path from "path"
9
9
import { loadEnv } from "read-config-file"
10
- import * as updateNotifier from "update-notifier"
11
10
import { ExecError } from "builder-util/out/util"
12
11
import { build , configureBuildCommand , createYargs } from "../builder"
13
12
import { createSelfSignedCert } from "./create-self-signed-cert"
@@ -47,7 +46,7 @@ void createYargs()
47
46
48
47
function wrap ( task : ( args : any ) = > Promise < any > ) {
49
48
return ( args : any ) => {
50
- checkIsOutdated ( )
49
+ checkIsOutdated ( ) . catch ( e => log . warn ( { error : e } , "cannot check updates" ) )
51
50
loadEnv ( path . join ( process . cwd ( ) , "electron-builder.env" ) )
52
51
. then ( ( ) => task ( args ) )
53
52
. catch ( error => {
@@ -63,29 +62,17 @@ function wrap(task: (args: any) => Promise<any>) {
63
62
}
64
63
}
65
64
66
- function checkIsOutdated ( ) {
65
+ async function checkIsOutdated ( ) {
67
66
if ( isCi || process . env . NO_UPDATE_NOTIFIER != null ) {
68
67
return
69
68
}
70
69
71
- readJson ( path . join ( __dirname , ".." , ".." , "package.json" ) )
72
- . then ( async it => {
73
- if ( it . version === "0.0.0-semantic-release" ) {
74
- return
75
- }
76
-
77
- const packageManager = ( await pathExists ( path . join ( __dirname , ".." , ".." , "package-lock.json" ) ) ) ? "npm" : "yarn"
78
-
79
- const notifier = updateNotifier ( { pkg : it } )
80
- if ( notifier . update != null ) {
81
- notifier . notify ( {
82
- message : `Update available ${ chalk . dim ( notifier . update . current ) } ${ chalk . reset ( " → " ) } ${ chalk . green ( notifier . update . latest ) } \nRun ${ chalk . cyan (
83
- `${ packageManager } upgrade electron-builder`
84
- ) } to update`,
85
- } )
86
- }
87
- } )
88
- . catch ( e => log . warn ( { error : e } , "cannot check updates" ) )
70
+ const pkg = await readJson ( path . join ( __dirname , ".." , ".." , "package.json" ) )
71
+ if ( pkg . version === "0.0.0-semantic-release" ) {
72
+ return
73
+ }
74
+ const UpdateNotifier = require ( "simple-update-notifier" )
75
+ await UpdateNotifier ( { pkg } )
89
76
}
90
77
91
78
async function rebuildAppNativeCode ( args : any ) {
0 commit comments