werewolf
This commit is contained in:
parent
06b9217fee
commit
56262f1f6f
29
packages/nano-remix/src/build.ts
Normal file
29
packages/nano-remix/src/build.ts
Normal 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 }
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user