From bbba3e1669783e3c946e80045d68f68dde7e97a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Sat, 9 Oct 2021 16:14:19 +0800 Subject: [PATCH] chore: Improve start time --- script/build-main.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/script/build-main.ts b/script/build-main.ts index a6e4b74..0858943 100644 --- a/script/build-main.ts +++ b/script/build-main.ts @@ -18,7 +18,7 @@ const spinner = ora(`${TAG} Electron main build...`) ; (async () => { if (argv.watch) { // Wait on vite server launched - await waitOn({ port: env.PORT as string }) + const waitOnState = waitOn({ port: env.PORT as string }) const watcher = watch(opt) let child: ChildProcess @@ -26,7 +26,9 @@ const spinner = ora(`${TAG} Electron main build...`) const log = chalk.green(`change -- ${filename}`) console.log(TAG, log) }) - watcher.on('event', ev => { + watcher.on('event', async ev => { + await waitOnState + if (ev.code === 'END') { if (child) child.kill() child = spawn( @@ -52,4 +54,3 @@ const spinner = ora(`${TAG} Electron main build...`) } } })(); -