@@ -11,7 +11,7 @@ const packager = require('electron-packager')
11
11
const { spawn } = require ( 'child_process' )
12
12
{ { / i f _ e q } }
13
13
const webpack = require ( 'webpack' )
14
- const Multispinner = require ( 'multispinner ' )
14
+ const Listr = require ( 'listr ' )
15
15
16
16
{ { #if_eq builder 'packager' } } const buildConfig = require ( './build.config' ) { { / i f _ e q } }
17
17
const mainConfig = require ( './webpack.main.config' )
@@ -33,7 +33,7 @@ function clean () {
33
33
process . exit ( )
34
34
}
35
35
36
- function build ( ) {
36
+ async function build ( ) {
37
37
greeting ( )
38
38
39
39
del . sync ( [ 'dist/electron/*' , '!.gitkeep' ] )
@@ -46,32 +46,49 @@ function build () {
46
46
47
47
let results = ''
48
48
49
- m . on ( 'success' , ( ) => {
50
- process . stdout . write ( '\x1B[2J\x1B[0f' )
51
- console . log ( `\n\n${ results } ` )
52
- console . log ( `${ okayLog } take it away ${ chalk . yellow ( '`electron-{{builder}}`' ) } \n` )
53
- { { #if_eq builder 'packager' } } bundleApp ( ) { { else } } process . exit ( ) { { / i f _ e q } }
54
- } )
55
-
56
- pack ( mainConfig ) . then ( result => {
57
- results += result + '\n\n'
58
- m . success ( 'main' )
59
- } ) . catch ( err => {
60
- m . error ( 'main' )
61
- console . log ( `\n ${ errorLog } failed to build main process` )
62
- console . error ( `\n${ err } \n` )
63
- process . exit ( 1 )
64
- } )
65
-
66
- pack ( rendererConfig ) . then ( result => {
67
- results += result + '\n\n'
68
- m . success ( 'renderer' )
69
- } ) . catch ( err => {
70
- m . error ( 'renderer' )
71
- console . log ( `\n ${ errorLog } failed to build renderer process` )
72
- console . error ( `\n${ err } \n` )
73
- process . exit ( 1 )
74
- } )
49
+ const tasks = new Listr (
50
+ [
51
+ {
52
+ title : 'building master process' ,
53
+ task : async ( ) => {
54
+ await pack ( mainConfig )
55
+ . then ( result => {
56
+ results += result + '\n\n'
57
+ } )
58
+ . catch ( err => {
59
+ console . log ( `\n ${ errorLog } failed to build main process` )
60
+ console . error ( `\n${ err } \n` )
61
+ } )
62
+ }
63
+ } ,
64
+ {
65
+ title : 'building renderer process' ,
66
+ task : async ( ) => {
67
+ await pack ( rendererConfig )
68
+ . then ( result => {
69
+ results += result + '\n\n'
70
+ } )
71
+ . catch ( err => {
72
+ console . log ( `\n ${ errorLog } failed to build renderer process` )
73
+ console . error ( `\n${ err } \n` )
74
+ } )
75
+ }
76
+ }
77
+ ] ,
78
+ { concurrent : 2 }
79
+ )
80
+
81
+ await tasks
82
+ . run ( )
83
+ . then ( ( ) => {
84
+ process . stdout . write ( '\x1B[2J\x1B[0f' )
85
+ console . log ( `\n\n${ results } ` )
86
+ console . log ( `${ okayLog } take it away ${ chalk . yellow ( '`electron-builder`' ) } \n` )
87
+ process . exit ( )
88
+ } )
89
+ . catch ( err => {
90
+ process . exit ( 1 )
91
+ } )
75
92
}
76
93
77
94
function pack ( config ) {
@@ -147,4 +164,4 @@ function greeting () {
147
164
} )
148
165
} else console . log ( chalk . yellow . bold ( '\n lets-build' ) )
149
166
console . log ( )
150
- }
167
+ }
0 commit comments