From 5b2f6a6d230f1d01ded658354392d2d1179f270d Mon Sep 17 00:00:00 2001 From: Matthew West Date: Mon, 22 Feb 2021 15:57:52 -0600 Subject: [PATCH] Clarify docs for ensureSymlink() in the case where destPath already exists The existing docs for `ensureSymlink()` don't specify what happens in the case where `destPath` already exists. Looking at the code it turns out that when `destFile` already exists the function exits without making any modifications, whether or not `destPath` is a symlink to `srcPath`: https://github.com/jprichardson/node-fs-extra/blob/1625838cdfc65a1bbf28ab5fa962a75805629b9c/lib/ensure/symlink.js#L26 I found this behavior surprising, because the function name `ensureSymlink()` sounds like it will ensure that the symlink `destPath -> srcPath` exists. This PR clarifies the existing behavior in the docs. --- docs/ensureSymlink.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ensureSymlink.md b/docs/ensureSymlink.md index 737da480e..51c8b12ef 100644 --- a/docs/ensureSymlink.md +++ b/docs/ensureSymlink.md @@ -1,6 +1,6 @@ # ensureSymlink(srcPath, destPath[, type][, callback]) -Ensures that the symlink exists. If the directory structure does not exist, it is created. +Ensures that the symlink exists. If the directory structure does not exist, it is created. If `destPath` already exists then it will not be updated, even if it is not a symlink to `srcPath`. **Alias:** `createSymlink()`