From 56262f1f6fd4e14d91bf987b483e1f8da05e0f61 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Mon, 7 Jul 2025 15:31:23 -0700 Subject: [PATCH] werewolf --- packages/nano-remix/src/build.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 packages/nano-remix/src/build.ts diff --git a/packages/nano-remix/src/build.ts b/packages/nano-remix/src/build.ts new file mode 100644 index 0000000..c08377e --- /dev/null +++ b/packages/nano-remix/src/build.ts @@ -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 } +}