Skip to content

Commit 9f2e47c

Browse files
committed
work
1 parent 278e682 commit 9f2e47c

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

src/dev/dev_build_cache.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type { FreshFileTransformer } from "./file_transformer.ts";
99
import { assertInDir } from "../utils.ts";
1010
import { ensureDir } from "@std/fs/ensure-dir";
1111
import { walk } from "@std/fs/walk";
12-
import { isDirectory } from "../fs.ts";
1312

1413
export interface MemoryFile {
1514
hash: string | null;
@@ -208,7 +207,7 @@ export class DiskBuildCache implements DevBuildCache {
208207
const staticDir = this.config.staticDir;
209208
const outDir = this.config.build.outDir;
210209

211-
if (await isDirectory(staticDir)) {
210+
try {
212211
const entries = walk(staticDir, {
213212
includeDirs: false,
214213
includeFiles: true,
@@ -242,6 +241,10 @@ export class DiskBuildCache implements DevBuildCache {
242241
this.addUnprocessedFile(pathname);
243242
}
244243
}
244+
} catch (error) {
245+
if (!(error instanceof Deno.errors.NotFound)) {
246+
throw error;
247+
}
245248
}
246249

247250
const snapshot: BuildSnapshot = {

src/fs.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/plugins/fs_routes/mod.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { type HandlerFn, isHandlerByMethod } from "../../handlers.ts";
1414
import { HttpError } from "../../error.ts";
1515
import { parseRootPath } from "../../config.ts";
1616
import type { FreshReqContext, PageProps } from "../../context.ts";
17-
import { isDirectory } from "../../fs.ts";
1817

1918
const TEST_FILE_PATTERN = /[._]test\.(?:[tj]sx?|[mc][tj]s)$/;
2019
const GROUP_REG = /(^|[/\\\\])\((_[^/\\\\]+)\)[/\\\\]/;
@@ -77,19 +76,26 @@ export async function fsRoutes<State>(
7776
const islandDir = path.join(dir, "islands");
7877
const routesDir = path.join(dir, "routes");
7978

80-
const islandPaths = await isDirectory(islandDir)
81-
? await Array.fromAsync(
82-
internals.walk(islandDir, {
79+
const islandPaths: string[] = [];
80+
const relRoutePaths: string[] = [];
81+
82+
try {
83+
for await (
84+
const entry of walk(islandDir, {
8385
includeDirs: false,
8486
exts: ["tsx", "jsx", "ts", "js"],
8587
skip,
86-
}),
87-
(entry) => entry.path,
88-
)
89-
: [];
88+
})
89+
) {
90+
islandPaths.push(entry.path);
91+
}
92+
} catch (error) {
93+
if (!(error instanceof Deno.errors.NotFound)) {
94+
throw error;
95+
}
96+
}
9097

91-
const relRoutePaths: string[] = [];
92-
if (await isDirectory(routesDir)) {
98+
try {
9399
for await (
94100
const entry of internals.walk(routesDir, {
95101
includeDirs: false,
@@ -113,6 +119,11 @@ export async function fsRoutes<State>(
113119
const url = new URL(relative, "http://localhost/");
114120
relRoutePaths.push(url.pathname.slice(1));
115121
}
122+
} catch (error) {
123+
// `islandDir` or `routesDir` does not exist, so we can skip it
124+
if (!(error instanceof Deno.errors.NotFound)) {
125+
throw error;
126+
}
116127
}
117128

118129
await Promise.all(islandPaths.map(async (islandPath) => {

0 commit comments

Comments
 (0)