(path)
| 45 | } |
| 46 | |
| 47 | async function readText(path) { |
| 48 | try { |
| 49 | const st = await stat(path); |
| 50 | if (!st.isFile()) return null; |
| 51 | if (st.size > MAX_READ_BYTES) { |
| 52 | const fh = await open(path, "r"); |
| 53 | try { |
| 54 | const buf = Buffer.alloc(MAX_READ_BYTES); |
| 55 | const { bytesRead } = await fh.read(buf, 0, MAX_READ_BYTES, 0); |
| 56 | return buf.toString("utf8", 0, bytesRead); |
| 57 | } finally { |
| 58 | await fh.close(); |
| 59 | } |
| 60 | } |
| 61 | return await readFile(path, "utf8"); |
| 62 | } catch { |
| 63 | return null; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | async function exists(path) { |
| 68 | try { |
no test coverage detected