From a559f85f7015beda740fefd5e6472c495e500bc6 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Mon, 30 Dec 2019 23:52:19 +0900
Subject: [PATCH] Replace multispinner with listr in build.js
---
template/.electron-vue/build.js | 75 ++++++++++++++++++++-------------
template/package.json | 2 +-
2 files changed, 47 insertions(+), 30 deletions(-)
diff --git a/template/.electron-vue/build.js b/template/.electron-vue/build.js
index dc624aaf..9523ea1b 100644
--- a/template/.electron-vue/build.js
+++ b/template/.electron-vue/build.js
@@ -11,7 +11,7 @@ const packager = require('electron-packager')
const { spawn } = require('child_process')
{{/if_eq}}
const webpack = require('webpack')
-const Multispinner = require('multispinner')
+const Listr = require('listr')
{{#if_eq builder 'packager'}}const buildConfig = require('./build.config'){{/if_eq}}
const mainConfig = require('./webpack.main.config')
@@ -33,7 +33,7 @@ function clean () {
process.exit()
}
-function build () {
+async function build () {
greeting()
del.sync(['dist/electron/*', '!.gitkeep'])
@@ -46,32 +46,49 @@ function build () {
let results = ''
- m.on('success', () => {
- process.stdout.write('\x1B[2J\x1B[0f')
- console.log(`\n\n${results}`)
- console.log(`${okayLog}take it away ${chalk.yellow('`electron-{{builder}}`')}\n`)
- {{#if_eq builder 'packager'}}bundleApp(){{else}}process.exit(){{/if_eq}}
- })
-
- pack(mainConfig).then(result => {
- results += result + '\n\n'
- m.success('main')
- }).catch(err => {
- m.error('main')
- console.log(`\n ${errorLog}failed to build main process`)
- console.error(`\n${err}\n`)
- process.exit(1)
- })
-
- pack(rendererConfig).then(result => {
- results += result + '\n\n'
- m.success('renderer')
- }).catch(err => {
- m.error('renderer')
- console.log(`\n ${errorLog}failed to build renderer process`)
- console.error(`\n${err}\n`)
- process.exit(1)
- })
+ const tasks = new Listr(
+ [
+ {
+ title: 'building master process',
+ task: async () => {
+ await pack(mainConfig)
+ .then(result => {
+ results += result + '\n\n'
+ })
+ .catch(err => {
+ console.log(`\n ${errorLog}failed to build main process`)
+ console.error(`\n${err}\n`)
+ })
+ }
+ },
+ {
+ title: 'building renderer process',
+ task: async () => {
+ await pack(rendererConfig)
+ .then(result => {
+ results += result + '\n\n'
+ })
+ .catch(err => {
+ console.log(`\n ${errorLog}failed to build renderer process`)
+ console.error(`\n${err}\n`)
+ })
+ }
+ }
+ ],
+ { concurrent: 2 }
+ )
+
+ await tasks
+ .run()
+ .then(() => {
+ process.stdout.write('\x1B[2J\x1B[0f')
+ console.log(`\n\n${results}`)
+ console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`)
+ process.exit()
+ })
+ .catch(err => {
+ process.exit(1)
+ })
}
function pack (config) {
@@ -147,4 +164,4 @@ function greeting () {
})
} else console.log(chalk.yellow.bold('\n lets-build'))
console.log()
-}
\ No newline at end of file
+}
diff --git a/template/package.json b/template/package.json
index fb6bfd21..480229ac 100644
--- a/template/package.json
+++ b/template/package.json
@@ -137,6 +137,7 @@
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^3.0.0",
{{/if}}
+ "listr": "^0.14.3",
{{#if e2e}}
"require-dir": "^1.0.0",
"spectron": "^3.8.0",
@@ -146,7 +147,6 @@
"chai": "^4.1.2",
"mocha": "^5.2.0",
{{/testing}}
- "multispinner": "^0.2.1",
"node-loader": "^0.6.0",
{{#if usesass}}
"node-sass": "^4.9.2",