major: import Fresh 2.0 code (#2449)

🎉
This commit is contained in:
Marvin Hagemeister
2024-05-24 09:40:08 +02:00
committed by GitHub
parent 990357629e
commit 287929e4d2
958 changed files with 15794 additions and 28287 deletions
+39
View File
@@ -0,0 +1,39 @@
import { walk, type WalkEntry, type WalkOptions } from "@std/fs/walk";
export interface FreshFile {
size: number;
readable: ReadableStream<Uint8Array>;
}
export interface FsAdapter {
walk(
root: string | URL,
options?: WalkOptions,
): AsyncIterableIterator<WalkEntry>;
isDirectory(path: string | URL): Promise<boolean>;
mkdirp(dir: string): Promise<void>;
readFile(path: string | URL): Promise<Uint8Array>;
}
export const fsAdapter: FsAdapter = {
walk,
async isDirectory(path) {
try {
const stat = await Deno.stat(path);
return stat.isDirectory;
} catch (err) {
if (err instanceof Deno.errors.NotFound) return false;
throw err;
}
},
async mkdirp(dir: string) {
try {
await Deno.mkdir(dir, { recursive: true });
} catch (err) {
if (!(err instanceof Deno.errors.AlreadyExists)) {
throw err;
}
}
},
readFile: Deno.readFile,
};