Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/node): Add fs.lutimes / fs.lutimesSync #23172

Merged
merged 10 commits into from
Jul 3, 2024
Merged
Prev Previous commit
Next Next commit
Export fs._toUnixTimestamp for compat
  • Loading branch information
nathanwhit committed Jul 1, 2024
commit 99844cd4984b20599288f4bc7bcfa2d4863310e7
5 changes: 5 additions & 0 deletions ext/node/polyfills/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 128,7 @@ import {
ReadStream,
WriteStream,
} from "ext:deno_node/internal/fs/streams.mjs";
import { toUnixTimestamp as _toUnixTimestamp } from "ext:deno_node/internal/fs/utils.mjs";

const {
F_OK,
Expand Down Expand Up @@ -291,9 292,13 @@ export default {
WriteStream,
writeSync,
X_OK,
// For tests
_toUnixTimestamp,
};

export {
// For tests
_toUnixTimestamp,
access,
accessSync,
appendFile,
Expand Down
4 changes: 3 additions & 1 deletion ext/node/polyfills/internal/fs/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 5,8 @@

"use strict";

import { primordials } from "ext:core/mod.js";
const { DatePrototypeGetTime } = primordials;
import { Buffer } from "node:buffer";
import {
ERR_FS_EISDIR,
Expand Down Expand Up @@ -698,7 700,7 @@ export function toUnixTimestamp(time, name = "time") {
}
if (isDate(time)) {
// Convert to 123.456 UNIX timestamp
return Date.getTime(time) / 1000;
return DatePrototypeGetTime(time) / 1000;
}
throw new ERR_INVALID_ARG_TYPE(name, ["Date", "Time in seconds"], time);
}
Expand Down