From 857c7ec0c3abc4428d8de1308b828ad5e65c3f0c Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sun, 28 Jul 2024 10:51:01 +0700 Subject: [PATCH] Update build script --- build.ts | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/build.ts b/build.ts index c78f9cb..6eb558d 100644 --- a/build.ts +++ b/build.ts @@ -89,14 +89,13 @@ const build = async (target: BuildTarget, version: string, config: any={}) => { // Check with ESLint const eslint = new ESLint(); - eslint.lintFiles([path]).then((results: any) => { - results[0].messages.forEach((msg: any) => { - console.error(`${path}#${msg.line}: ${msg.message}`); - }); - - console.log(`---- [${target}] done in ${performance.now() - startTime} ms`); - console.log(`---- [${target}] ${new Date()}`); + const results = await eslint.lintFiles([path]); + results[0].messages.forEach((msg: any) => { + console.error(`${path}#${msg.line}: ${msg.message}`); }); + + console.log(`---- [${target}] done in ${performance.now() - startTime} ms`); + console.log(`---- [${target}] ${new Date()}`); } const buildTargets = [ @@ -123,9 +122,26 @@ if (!values['version']) { sys.exit(-1); } -console.log('Building: ', values['version']); +async function main() { + const config = {}; + console.log('Building: ', values['version']); + for (const target of buildTargets) { + await build(target, values['version']!!, config); + } -const config = {}; -for (const target of buildTargets) { - await build(target, values['version']!!, config); + console.log('\n** Press Enter to build or Esc to exit'); } + +function onKeyPress(data: any) { + const keyCode = data[0]; + if (keyCode === 13) { // Enter key + main(); + } else if (keyCode === 27) { // Esc key + process.exit(0); + } +} + +main(); +process.stdin.setRawMode(true); +process.stdin.resume(); +process.stdin.on('data', onKeyPress);