(path, data, options)
| 497 | ) |
| 498 | |
| 499 | const writeFile: FileSystem.FileSystem["writeFile"] = (path, data, options) => { |
| 500 | const flag = options?.flag ?? "w" |
| 501 | if (options?.mode === undefined && (flag === "w" || flag === "wx" || flag === "a" || flag === "ax")) { |
| 502 | return tryPromise("writeFile", path, (signal) => |
| 503 | Deno.writeFile(path, data, { |
| 504 | append: flag.startsWith("a"), |
| 505 | createNew: flag.includes("x"), |
| 506 | signal |
| 507 | })) |
| 508 | } |
| 509 | return Effect.acquireUseRelease( |
| 510 | tryPromise("writeFile", path, () => Deno.open(path, openOptions(flag, options?.mode))), |
| 511 | (file) => |
| 512 | new FileImpl(file, flag.startsWith("a")).writeAll(data).pipe( |
| 513 | Effect.mapError((error) => |
| 514 | error.reason._tag !== "BadArgument" |
| 515 | ? PlatformError.systemError({ ...error.reason, method: "writeFile", pathOrDescriptor: path }) |
| 516 | : error |
| 517 | ) |
| 518 | ), |
| 519 | (file) => close(file, "writeFile", path) |
| 520 | ) |
| 521 | } |
| 522 | |
| 523 | const makeFileSystem = Effect.map(Effect.serviceOption(FileSystem.WatchBackend), (backend) => |
| 524 | FileSystem.make({ |
nothing calls this directly
no test coverage detected