(method: string)
| 182 | (error.reason.cause as NodeJS.ErrnoException | undefined)?.code === "ERR_FS_EISDIR" |
| 183 | |
| 184 | const removeFactory = (method: string): FileSystem.FileSystem["remove"] => { |
| 185 | const nodeRm = effectify( |
| 186 | NFS.rm, |
| 187 | handleErrnoException("FileSystem", method), |
| 188 | handleBadArgument(method) |
| 189 | ) |
| 190 | const nodeRmdir = effectify( |
| 191 | NFS.rmdir, |
| 192 | handleErrnoException("FileSystem", method), |
| 193 | handleBadArgument(method) |
| 194 | ) |
| 195 | return (path, options) => { |
| 196 | const force = options?.force ?? false |
| 197 | const effect = nodeRm(path, { recursive: options?.recursive ?? false, force }) |
| 198 | if (options?.recursive) return effect |
| 199 | // `rm` rejects all directories; `rmdir` atomically removes only empty ones |
| 200 | return Effect.catchIf(effect, isEisdir, () => { |
| 201 | const rmdir = nodeRmdir(path) |
| 202 | return force ? Effect.catchIf(rmdir, (error) => error.reason._tag === "NotFound", () => Effect.void) : rmdir |
| 203 | }) |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | const remove = removeFactory("remove") |
| 208 |
no test coverage detected