Fix PWD env var usage and import path

This commit is contained in:
Chris Wanstrath 2026-03-23 23:19:58 -07:00
parent 0f224f89e9
commit 8222180ff4
2 changed files with 3 additions and 3 deletions

View File

@ -181,7 +181,7 @@ export class Hype<
if (pageName.split('/').some(s => s.startsWith('_'))) return render404(c)
// try pageName.tsx, then pageName/index.tsx
const base = join(process.cwd(), './src/pages')
const base = join(process.env.PWD ?? process.cwd(), './src/pages')
let path = join(base, `${pageName}.tsx`)
if (!(await Bun.file(path).exists())) {
path = join(base, `${pageName}/index.tsx`)
@ -190,7 +190,7 @@ export class Hype<
}
let Layout = defaultLayout
const layoutPath = join(process.cwd(), `./src/pages/_layout.tsx`)
const layoutPath = join(process.env.PWD ?? process.cwd(), `./src/pages/_layout.tsx`)
if (await Bun.file(layoutPath).exists()) {
Layout = pageCache.get(layoutPath)
if (!Layout) {

View File

@ -1,5 +1,5 @@
import { test, expect } from "bun:test"
import { Hype } from "./index.tsx"
import { Hype } from "../index.tsx"
test("defaults returns next available port in dev mode", () => {
// Start a server on port 4000 to block it