(path, data, options)
| 440 | ) |
| 441 | |
| 442 | const writeFile: FileSystem.FileSystem["writeFile"] = (path, data, options) => { |
| 443 | const flag = options?.flag ?? "w" |
| 444 | if (flag === "w" || flag === "wx" || flag === "a" || flag === "ax") { |
| 445 | return tryPromise("writeFile", path, (signal) => |
| 446 | Deno.writeFile(path, data, { |
| 447 | append: flag.startsWith("a"), |
| 448 | createNew: flag.includes("x"), |
| 449 | ...(options?.mode === undefined ? {} : { mode: options.mode }), |
| 450 | signal |
| 451 | })) |
| 452 | } |
| 453 | return Effect.acquireUseRelease( |
| 454 | tryPromise("writeFile", path, () => Deno.open(path, openOptions(flag, options?.mode))), |
| 455 | (file) => |
| 456 | new FileImpl(file, flag.startsWith("a")).writeAll(data).pipe( |
| 457 | Effect.mapError((error) => |
| 458 | error.reason._tag !== "BadArgument" |
| 459 | ? PlatformError.systemError({ ...error.reason, method: "writeFile", pathOrDescriptor: path }) |
| 460 | : error |
| 461 | ) |
| 462 | ), |
| 463 | (file) => close(file, "writeFile", path) |
| 464 | ) |
| 465 | } |
| 466 | |
| 467 | const makeFileSystem = Effect.map(Effect.serviceOption(FileSystem.WatchBackend), (backend) => |
| 468 | FileSystem.make({ |
nothing calls this directly
no test coverage detected