From 40eb0a449283b7849122c4b1909ace43996f33d3 Mon Sep 17 00:00:00 2001 From: Federico Di Leo <38290480+FedeIlLeone@users.noreply.github.com> Date: Mon, 24 Jun 2024 01:32:54 +0200 Subject: [PATCH] fix(scripts): catch and exit if building fails (#634) --- bin/index.mts | 10 +++++++--- scripts/build.mts | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/index.mts b/bin/index.mts index 05570f840..1fde60ba3 100755 --- a/bin/index.mts +++ b/bin/index.mts @@ -272,7 +272,7 @@ async function handleContexts( if (watch) { await context.watch(); } else { - await context.rebuild().catch(() => {}); + await context.rebuild().catch(() => process.exit(1)); context.dispose(); } }), @@ -364,7 +364,9 @@ async function buildPlugin({ watch, noInstall, production, noReload, addon }: Ar const install: esbuild.Plugin = { name: "install", setup: (build) => { - build.onEnd(async () => { + build.onEnd(async (result) => { + if (result.errors.length > 0) return; + if (!noInstall) { const dest = path.join(CONFIG_PATH, "plugins", manifest.id); if (existsSync(dest)) rmSync(dest, { recursive: true, force: true }); @@ -452,7 +454,9 @@ async function buildTheme({ watch, noInstall, production, noReload, addon }: Arg const install: esbuild.Plugin = { name: "install", setup: (build) => { - build.onEnd(async () => { + build.onEnd(async (result) => { + if (result.errors.length > 0) return; + if (!noInstall) { const dest = path.join(CONFIG_PATH, "themes", manifest.id); if (existsSync(dest)) rmSync(dest, { recursive: true, force: true }); diff --git a/scripts/build.mts b/scripts/build.mts index 8e314b2fe..ff10da1c2 100644 --- a/scripts/build.mts +++ b/scripts/build.mts @@ -33,7 +33,9 @@ rmSync("replugged.asar", { force: true }); const preBundle: esbuild.Plugin = { name: "preBundle", setup: (build) => { - build.onEnd(() => { + build.onEnd((result) => { + if (result.errors.length > 0) return; + if (!existsSync(`${distDir}/i18n`)) { mkdirSync(`${distDir}/i18n`); } @@ -114,7 +116,7 @@ await Promise.all( if (watch) { await context.watch(); } else { - await context.rebuild().catch(() => {}); + await context.rebuild().catch(() => process.exit(1)); context.dispose(); } }),