| 21689 | this.fileCache = {} |
| 21690 | } |
| 21691 | async _read(absolutePath) { |
| 21692 | if (isUrl(absolutePath)) { |
| 21693 | const result = await fetchWithCache(absolutePath) |
| 21694 | return { |
| 21695 | absolutePath, |
| 21696 | exists: result.exists, |
| 21697 | content: result.content, |
| 21698 | stats: { mtimeMs: Date.now(), ctimeMs: Date.now() } |
| 21699 | } |
| 21700 | } |
| 21701 | const { fileCache } = this |
| 21702 | if (fileCache[absolutePath]) return fileCache[absolutePath] |
| 21703 | try { |
| 21704 | const stats = await fsp.stat(absolutePath) |
| 21705 | const content = await fsp.readFile(absolutePath, { |
| 21706 | encoding: "utf8", |
| 21707 | flag: "r" // explicit read flag |
| 21708 | }) |
| 21709 | const normalizedContent = content.includes("\r") ? content.replace(/\r/g, "") : content |
| 21710 | fileCache[absolutePath] = { |
| 21711 | absolutePath, |
| 21712 | exists: true, |
| 21713 | content: normalizedContent, |
| 21714 | stats |
| 21715 | } |
| 21716 | } catch (error) { |
| 21717 | fileCache[absolutePath] = { |
| 21718 | absolutePath, |
| 21719 | exists: false, |
| 21720 | content: "", |
| 21721 | stats: { mtimeMs: 0, ctimeMs: 0 } |
| 21722 | } |
| 21723 | } |
| 21724 | return fileCache[absolutePath] |
| 21725 | } |
| 21726 | async exists(absolutePath) { |
| 21727 | if (isUrl(absolutePath)) { |
| 21728 | const result = await fetchWithCache(absolutePath) |