MCPcopy Create free account
hub / github.com/denoland/std / removeSync

Function removeSync

fs/unstable_remove.ts:81–103  ·  view source on GitHub ↗
(
  path: string | URL,
  options?: RemoveOptions,
)

Source from the content-addressed store, hash-verified

79 * @param options Options when reading a file. See {@linkcode RemoveOptions}.
80 */
81export 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}

Calls 2

getNodeFsFunction · 0.90
mapErrorFunction · 0.90

Tested by

no test coverage detected