Fix PWD env var usage and import path
This commit is contained in:
parent
0f224f89e9
commit
8222180ff4
|
|
@ -181,7 +181,7 @@ export class Hype<
|
||||||
if (pageName.split('/').some(s => s.startsWith('_'))) return render404(c)
|
if (pageName.split('/').some(s => s.startsWith('_'))) return render404(c)
|
||||||
|
|
||||||
// try pageName.tsx, then pageName/index.tsx
|
// 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`)
|
let path = join(base, `${pageName}.tsx`)
|
||||||
if (!(await Bun.file(path).exists())) {
|
if (!(await Bun.file(path).exists())) {
|
||||||
path = join(base, `${pageName}/index.tsx`)
|
path = join(base, `${pageName}/index.tsx`)
|
||||||
|
|
@ -190,7 +190,7 @@ export class Hype<
|
||||||
}
|
}
|
||||||
|
|
||||||
let Layout = defaultLayout
|
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()) {
|
if (await Bun.file(layoutPath).exists()) {
|
||||||
Layout = pageCache.get(layoutPath)
|
Layout = pageCache.get(layoutPath)
|
||||||
if (!Layout) {
|
if (!Layout) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { test, expect } from "bun:test"
|
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", () => {
|
test("defaults returns next available port in dev mode", () => {
|
||||||
// Start a server on port 4000 to block it
|
// Start a server on port 4000 to block it
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user