This commit is contained in:
Corey Johnson 2025-07-07 15:31:23 -07:00
parent 06b9217fee
commit 56262f1f6f

View File

@ -0,0 +1,29 @@
import { join } from "node:path"
export type BuildRouteOptions = {
distDir: string
routeName: string
filepath: string
}
export const buildDynamicRoute = async ({ distDir, routeName, filepath }: BuildRouteOptions) => {
const scriptPath = join(import.meta.dirname, "../scripts/build.ts")
const proc = Bun.spawn({
cmd: ["bun", "run", scriptPath, distDir, routeName, filepath],
stdout: "pipe",
stderr: "pipe",
})
const exitCode = await proc.exited
if (exitCode !== 0) {
const stderr = await new Response(proc.stderr).text()
throw new Error(`Build process failed with exit code ${exitCode}: ${stderr}`)
}
const stdout = await new Response(proc.stdout).text()
console.log(stdout)
return { success: true }
}