( path: string | URL, options?: RemoveOptions, )
| 79 | * @param options Options when reading a file. See {@linkcode RemoveOptions}. |
| 80 | */ |
| 81 | export function removeSync( |
| 82 | path: string | URL, |
| 83 | options?: RemoveOptions, |
| 84 | ) { |
| 85 | if (isDeno) { |
| 86 | Deno.removeSync(path, options); |
| 87 | } else { |
| 88 | const { recursive = false } = options ?? {}; |
| 89 | try { |
| 90 | getNodeFs().rmSync(path, { recursive: recursive }); |
| 91 | } catch (error) { |
| 92 | if ((error as Error & { code: string }).code === "ERR_FS_EISDIR") { |
| 93 | try { |
| 94 | getNodeFs().rmdirSync(path); |
| 95 | } catch (error) { |
| 96 | throw mapError(error); |
| 97 | } |
| 98 | return; |
| 99 | } |
| 100 | throw mapError(error); |
| 101 | } |
| 102 | } |
| 103 | } |
no test coverage detected