MCPcopy Create free account
hub / github.com/Effect-TS/effect / writeFile

Function writeFile

packages/platform/node-shared/src/NodeFileSystem.ts:615–632  ·  view source on GitHub ↗
(path, data, options)

Source from the content-addressed store, hash-verified

613// == writeFile
614
615const writeFile: FileSystem.FileSystem["writeFile"] = (path, data, options) =>
616 Effect.callback<void, Error.PlatformError>((resume, signal) => {
617 try {
618 NFS.writeFile(path, data, {
619 signal,
620 flag: options?.flag,
621 mode: options?.mode
622 }, (err) => {
623 if (err) {
624 resume(Effect.fail(handleErrnoException("FileSystem", "writeFile")(err, [path])))
625 } else {
626 resume(Effect.void)
627 }
628 })
629 } catch (err) {
630 resume(Effect.fail(handleBadArgument("writeFile")(err)))
631 }
632 })
633
634const makeFileSystem = Effect.map(Effect.serviceOption(FileSystem.WatchBackend), (backend) =>
635 FileSystem.make({

Callers 2

makeTempFileFactoryFunction · 0.70

Calls 4

handleErrnoExceptionFunction · 0.90
handleBadArgumentFunction · 0.85
resumeFunction · 0.50
failMethod · 0.45

Tested by

no test coverage detected