fix(ext/node): export promise based lchown and lutimes from node:fs/promises (#29870)

The promised based `lchown` and `lutimes` were implemented in #24418 and
#23172 , but haven't been exported through the `node:fs/promises`
namespace.

Signed-off-by: Daniel Osvaldo R <daniel.rahmanto@gmail.com>
This commit is contained in:
Daniel Osvaldo R 2025-06-26 23:55:47 +07:00 committed by GitHub
parent ec32c6e5ba
commit e69a668e1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 2 deletions

View file

@ -37,6 +37,8 @@ import {
copyFile,
cp,
FileHandle,
lchown,
lutimes,
open,
stat,
writeFile,
@ -407,3 +409,36 @@ Deno.test("[node/fs] fchmodSync works", {
closeSync(fd);
Deno.removeSync(tempFile);
});
Deno.test("[node/fs/promises] lchown works", {
ignore: Deno.build.os === "windows",
}, async () => {
const tempFile = Deno.makeTempFileSync();
const symlinkPath = tempFile + "-link";
Deno.symlinkSync(tempFile, symlinkPath);
const uid = await execCmd("id -u");
const gid = await execCmd("id -g");
await lchown(symlinkPath, +uid, +gid);
Deno.removeSync(tempFile);
Deno.removeSync(symlinkPath);
});
Deno.test("[node/fs/promises] lutimes works", {
ignore: Deno.build.os === "windows",
}, async () => {
const tempFile = Deno.makeTempFileSync();
const symlinkPath = tempFile + "-link";
Deno.symlinkSync(tempFile, symlinkPath);
const date = new Date("1970-01-01T00:00:00Z");
await lutimes(symlinkPath, date, date);
const stats = Deno.lstatSync(symlinkPath);
assertEquals((stats.atime as Date).getTime(), date.getTime());
assertEquals((stats.mtime as Date).getTime(), date.getTime());
Deno.removeSync(tempFile);
Deno.removeSync(symlinkPath);
});