summaryrefslogtreecommitdiff
path: root/cli/ops
diff options
context:
space:
mode:
authorRafael Vargas <vargas.rafael9@gmail.com>2020-02-03 10:20:15 -0300
committerGitHub <noreply@github.com>2020-02-03 08:20:15 -0500
commit55063dd8e8e3ae52eb90bdf42e36d979dcbb5010 (patch)
treedeaa0b366a67d60d5a2bd4afdbed38fa845e0e48 /cli/ops
parentf168597b7ab81afda3bf4749a81c360d364e7cf1 (diff)
fix: Deno.remove() to properly remove dangling symlinks (#3860)
For some reason, the unit tests for Deno.remove() were not being imported to unit_tests.ts and, consequently, not being executed. Thus, I imported them, refactored some existent ones and wrote new ones for the symlink removal case. Since the creation of a symlink is not implemented for Windows yet, assertions that consider this state were added when the tests are executed in this OS.
Diffstat (limited to 'cli/ops')
-rw-r--r--cli/ops/fs.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/cli/ops/fs.rs b/cli/ops/fs.rs
index 61bc06d68..d5ce59f99 100644
--- a/cli/ops/fs.rs
+++ b/cli/ops/fs.rs
@@ -168,8 +168,9 @@ fn op_remove(
let is_sync = args.promise_id.is_none();
blocking_json(is_sync, move || {
debug!("op_remove {}", path.display());
- let metadata = fs::metadata(&path)?;
- if metadata.is_file() {
+ let metadata = fs::symlink_metadata(&path)?;
+ let file_type = metadata.file_type();
+ if file_type.is_file() || file_type.is_symlink() {
fs::remove_file(&path)?;
} else if recursive {
remove_dir_all(&path)?;