(params)
| 163 | }, |
| 164 | |
| 165 | async readFile(params) { |
| 166 | const record = asRecord(params) |
| 167 | const targetPath = stringValue(record, "path") |
| 168 | const encoding = encodingValue(record.encoding) |
| 169 | const maxReadSize = positiveInt(record.maxReadSize, DEFAULT_MAX_READ_SIZE) |
| 170 | const stat = await fs.stat(targetPath) |
| 171 | if (!stat.isFile()) return { type: "error", path: targetPath, message: "Path is not a file" } |
| 172 | if (stat.size > maxReadSize) return { type: "file", path: targetPath, size: stat.size, encoding, tooLarge: true, content: null } |
| 173 | return { |
| 174 | type: "file", |
| 175 | path: targetPath, |
| 176 | size: stat.size, |
| 177 | encoding, |
| 178 | tooLarge: false, |
| 179 | content: await fs.readFile(targetPath, encoding), |
| 180 | } |
| 181 | }, |
| 182 | |
| 183 | async writeFile(params) { |
| 184 | const record = asRecord(params) |
no test coverage detected