fs: refactor promises version of lchown and lchmod

Check for platform support first to save a level of indentation.

PR-URL: https://github.com/nodejs/node/pull/20551
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
cjihrig authored and Myles Borins committed 2018-05-22 14:09:48 -04:00
1 parent 6ce589f7f4
commit e5a0c197bd
1 file changed
+10 -12
+10 -12
View File
@@ -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) {