(files: Record<string, unknown>)
| 101 | } |
| 102 | |
| 103 | export function createFakeFs(files: Record<string, unknown>): FsAdapter { |
| 104 | return { |
| 105 | cwd: () => ".", |
| 106 | async *walk(_root, options) { |
| 107 | const skip = options?.skip ?? []; |
| 108 | for (const file of Object.keys(files)) { |
| 109 | // Check if file matches any skip pattern |
| 110 | if (skip.some((pattern) => pattern.test(file))) { |
| 111 | continue; |
| 112 | } |
| 113 | |
| 114 | const entry: WalkEntry = { |
| 115 | isDirectory: false, |
| 116 | isFile: true, |
| 117 | isSymlink: false, |
| 118 | name: file, |
| 119 | path: file, |
| 120 | }; |
| 121 | yield entry; |
| 122 | } |
| 123 | }, |
| 124 | // deno-lint-ignore require-await |
| 125 | async isDirectory(dir) { |
| 126 | return Object.keys(files).some((file) => file.startsWith(dir + "/")); |
| 127 | }, |
| 128 | async mkdirp(_dir: string) { |
| 129 | }, |
| 130 | readFile: Deno.readFile, |
| 131 | // deno-lint-ignore require-await |
| 132 | async readTextFile(path) { |
| 133 | return String(files[String(path)]); |
| 134 | }, |
| 135 | }; |
| 136 | } |
| 137 | |
| 138 | export const delay = (ms: number) => new Promise((r) => setTimeout(r, ms)); |
| 139 |
no outgoing calls
no test coverage detected