mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
parent
550556e948
commit
64bd2768f7
2 changed files with 29 additions and 1 deletions
|
@ -417,8 +417,11 @@ fn op_remove(
|
|||
std::fs::remove_file(&path)?;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if file_type.is_dir() {
|
||||
std::fs::remove_dir(&path)?;
|
||||
} else {
|
||||
// pipes, sockets, etc...
|
||||
std::fs::remove_file(&path)?;
|
||||
}
|
||||
Ok(json!({}))
|
||||
})
|
||||
|
|
|
@ -460,6 +460,31 @@ unitTest({ perms: { write: false } }, async function removeAllPerm(): Promise<
|
|||
assertEquals(err.name, "PermissionDenied");
|
||||
});
|
||||
|
||||
unitTest(
|
||||
{
|
||||
ignore: Deno.build.os === "windows",
|
||||
perms: { write: true, read: true },
|
||||
},
|
||||
async function removeUnixSocketSuccess(): Promise<void> {
|
||||
for (const method of ["remove", "removeSync"] as const) {
|
||||
// MAKE TEMPORARY UNIX SOCKET
|
||||
const path = Deno.makeTempDirSync() + "/test.sock";
|
||||
const listener = Deno.listen({ transport: "unix", path });
|
||||
listener.close();
|
||||
Deno.statSync(path); // check if unix socket exists
|
||||
|
||||
await Deno[method](path);
|
||||
let err;
|
||||
try {
|
||||
Deno.statSync(path);
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
assert(err instanceof Deno.errors.NotFound);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (Deno.build.os === "windows") {
|
||||
unitTest(
|
||||
{ perms: { run: true, write: true, read: true } },
|
||||
|
|
Loading…
Reference in a new issue