| 140 | ): T.Effect<OT.HasTracer, RmError | FileOrDirNotFoundError, void> |
| 141 | |
| 142 | function rm( |
| 143 | path: string, |
| 144 | params: { force?: boolean; recursive?: boolean } = {}, |
| 145 | ): T.Effect<OT.HasTracer, RmError | FileOrDirNotFoundError, void> { |
| 146 | const { force = false, recursive = true } = params |
| 147 | return OT.withSpan('rm', { attributes: { path } })( |
| 148 | T.tryCatchPromise( |
| 149 | () => fs.rm(path, { recursive, force }), |
| 150 | (error: any) => { |
| 151 | if (error.code === 'ENOENT') { |
| 152 | return new FileOrDirNotFoundError({ path }) |
| 153 | } else { |
| 154 | return new RmError({ path, error }) |
| 155 | } |
| 156 | }, |
| 157 | ), |
| 158 | ) |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * NOTE: symlinks are not supported widely on Windows |