| 181 | }, |
| 182 | |
| 183 | async writeFile(params) { |
| 184 | const record = asRecord(params) |
| 185 | const targetPath = stringValue(record, "path") |
| 186 | const encoding = encodingValue(record.encoding) |
| 187 | const content = typeof record.content === "string" ? record.content : "" |
| 188 | if (boolValue(record.createDirectory)) await fs.mkdir(path.dirname(targetPath), { recursive: true }) |
| 189 | await fs.writeFile(targetPath, content, encoding) |
| 190 | const stat = await fs.stat(targetPath) |
| 191 | return { ok: true, path: targetPath, size: stat.size, encoding } |
| 192 | }, |
| 193 | |
| 194 | async createDirectory(params) { |
| 195 | const record = asRecord(params) |