chore: Improve start time

This commit is contained in:
草鞋没号 2021-10-09 16:14:19 +08:00
parent 072a0791b1
commit bbba3e1669

View File

@ -18,7 +18,7 @@ const spinner = ora(`${TAG} Electron main build...`)
; (async () => { ; (async () => {
if (argv.watch) { if (argv.watch) {
// Wait on vite server launched // Wait on vite server launched
await waitOn({ port: env.PORT as string }) const waitOnState = waitOn({ port: env.PORT as string })
const watcher = watch(opt) const watcher = watch(opt)
let child: ChildProcess let child: ChildProcess
@ -26,7 +26,9 @@ const spinner = ora(`${TAG} Electron main build...`)
const log = chalk.green(`change -- ${filename}`) const log = chalk.green(`change -- ${filename}`)
console.log(TAG, log) console.log(TAG, log)
}) })
watcher.on('event', ev => { watcher.on('event', async ev => {
await waitOnState
if (ev.code === 'END') { if (ev.code === 'END') {
if (child) child.kill() if (child) child.kill()
child = spawn( child = spawn(
@ -52,4 +54,3 @@ const spinner = ora(`${TAG} Electron main build...`)
} }
} }
})(); })();