mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
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:
parent
ec32c6e5ba
commit
e69a668e1f
2 changed files with 37 additions and 2 deletions
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue