Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ async function chmod(path, mode) {

async function lchmod(path, mode) {
if (O_SYMLINK === undefined)
throw new ERR_METHOD_NOT_IMPLEMENTED();
throw new ERR_METHOD_NOT_IMPLEMENTED('lchmod()');

const fd = await open(path, O_WRONLY | O_SYMLINK);
return fchmod(fd, mode).finally(fd.close.bind(fd));
Expand Down
15 changes: 13 additions & 2 deletions test/parallel/test-fs-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,26 @@ function verifyStatObject(stat) {
(await realpath(newLink)).toLowerCase());
assert.strictEqual(newPath.toLowerCase(),
(await readlink(newLink)).toLowerCase());

const newMode = 0o666;
if (common.isOSX) {
// lchmod is only available on macOS
const newMode = 0o666;
await lchmod(newLink, newMode);
stats = await lstat(newLink);
assert.strictEqual(stats.mode & 0o777, newMode);
} else {
await Promise.all([
assert.rejects(
lchmod(newLink, newMode),
common.expectsError({
code: 'ERR_METHOD_NOT_IMPLEMENTED',
type: Error,
message: 'The lchmod() method is not implemented'
})
)
]);
}


await unlink(newLink);
}

Expand Down