diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index eb913adcbf975b..a80a5283c52e3c 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -376,21 +376,19 @@ async function chmod(path, mode) { } async function lchmod(path, mode) { - if (O_SYMLINK !== undefined) { - const fd = await open(path, - O_WRONLY | O_SYMLINK); - return fchmod(fd, mode).finally(fd.close.bind(fd)); - } - throw new ERR_METHOD_NOT_IMPLEMENTED(); + if (O_SYMLINK === undefined) + throw new ERR_METHOD_NOT_IMPLEMENTED(); + + const fd = await open(path, O_WRONLY | O_SYMLINK); + return fchmod(fd, mode).finally(fd.close.bind(fd)); } async function lchown(path, uid, gid) { - if (O_SYMLINK !== undefined) { - const fd = await open(path, - O_WRONLY | O_SYMLINK); - return fchown(fd, uid, gid).finally(fd.close.bind(fd)); - } - throw new ERR_METHOD_NOT_IMPLEMENTED(); + if (O_SYMLINK === undefined) + throw new ERR_METHOD_NOT_IMPLEMENTED(); + + const fd = await open(path, O_WRONLY | O_SYMLINK); + return fchown(fd, uid, gid).finally(fd.close.bind(fd)); } async function fchown(handle, uid, gid) {