Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scripts): catch and exit if building fails #634

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions bin/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}),
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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 });
Expand Down
6 changes: 4 additions & 2 deletions scripts/build.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
Expand Down Expand Up @@ -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();
}
}),
Expand Down
Loading