fix: exit process with a status code when build fails (#11206)

Fixes: FRMW-2897
CLOSES CLO-434

Still need the frontend Admin bundler to provide some way to know if the build has failed or not.
This commit is contained in:
Harminder Virk
2025-01-29 08:34:47 +00:00
committed by GitHub
parent 1e6f47d662
commit 716de2cb3a
4 changed files with 37 additions and 23 deletions
+12 -9
View File
@@ -1,21 +1,24 @@
import { Compiler } from "@medusajs/framework/build-tools"
import { logger } from "@medusajs/framework/logger"
export default async function build({
directory,
}: {
directory: string
}): Promise<boolean> {
export default async function build({ directory }: { directory: string }) {
logger.info("Starting build...")
const compiler = new Compiler(directory, logger)
const tsConfig = await compiler.loadTSConfigFile()
if (!tsConfig) {
logger.error("Unable to compile plugin")
return false
process.exit(1)
}
const bundler = await import("@medusajs/admin-bundler")
await compiler.buildPluginBackend(tsConfig)
await compiler.buildPluginAdminExtensions(bundler)
return true
const responses = await Promise.all([
compiler.buildPluginBackend(tsConfig),
compiler.buildPluginAdminExtensions(bundler),
])
if (responses.every((response) => response === true)) {
process.exit(0)
} else {
process.exit(1)
}
}