mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +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
|
@ -21,10 +21,10 @@ export const link = fsPromises.link;
|
||||||
export const unlink = fsPromises.unlink;
|
export const unlink = fsPromises.unlink;
|
||||||
export const chmod = fsPromises.chmod;
|
export const chmod = fsPromises.chmod;
|
||||||
export const lchmod = fsPromises.lchmod;
|
export const lchmod = fsPromises.lchmod;
|
||||||
// export const lchown = fs.lchown;
|
export const lchown = fsPromises.lchown;
|
||||||
export const chown = fsPromises.chown;
|
export const chown = fsPromises.chown;
|
||||||
export const utimes = fsPromises.utimes;
|
export const utimes = fsPromises.utimes;
|
||||||
// export const lutimes = fs.lutimes;
|
export const lutimes = fsPromises.lutimes;
|
||||||
export const realpath = fsPromises.realpath;
|
export const realpath = fsPromises.realpath;
|
||||||
export const mkdtemp = fsPromises.mkdtemp;
|
export const mkdtemp = fsPromises.mkdtemp;
|
||||||
export const writeFile = fsPromises.writeFile;
|
export const writeFile = fsPromises.writeFile;
|
||||||
|
|
|
@ -37,6 +37,8 @@ import {
|
||||||
copyFile,
|
copyFile,
|
||||||
cp,
|
cp,
|
||||||
FileHandle,
|
FileHandle,
|
||||||
|
lchown,
|
||||||
|
lutimes,
|
||||||
open,
|
open,
|
||||||
stat,
|
stat,
|
||||||
writeFile,
|
writeFile,
|
||||||
|
@ -407,3 +409,36 @@ Deno.test("[node/fs] fchmodSync works", {
|
||||||
closeSync(fd);
|
closeSync(fd);
|
||||||
Deno.removeSync(tempFile);
|
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