Skip to content

Commit

Permalink
fix(ext/node): test
Browse files Browse the repository at this point in the history
  • Loading branch information
ZYSzys committed Jan 15, 2025
1 parent 04973b7 commit 6e803d2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ext/node/polyfills/_fs/_fs_fdatasync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
import { FsFile } from "ext:deno_fs/30_fs.js";
import { promisify } from "ext:deno_node/internal/util.mjs";

export function fdatasync(
fd: number,
Expand All @@ -19,3 +20,7 @@ export function fdatasync(
export function fdatasyncSync(fd: number) {
new FsFile(fd, Symbol.for("Deno.internal.FsFile")).syncDataSync();
}

export const fdatasyncPromise = promisify(fdatasync) as (
fd: number,
) => Promise<void>;
3 changes: 3 additions & 0 deletions ext/node/polyfills/_fs/_fs_fsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
import { FsFile } from "ext:deno_fs/30_fs.js";
import { promisify } from "ext:deno_node/internal/util.mjs";

export function fsync(
fd: number,
Expand All @@ -19,3 +20,5 @@ export function fsync(
export function fsyncSync(fd: number) {
new FsFile(fd, Symbol.for("Deno.internal.FsFile")).syncSync();
}

export const fsyncPromise = promisify(fsync) as (fd: number) => Promise<void>;
6 changes: 4 additions & 2 deletions ext/node/polyfills/internal/fs/handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
import { ftruncatePromise } from "ext:deno_node/_fs/_fs_ftruncate.ts";
export type { BigIntStats, Stats } from "ext:deno_node/_fs/_fs_stat.ts";
import { writevPromise, WriteVResult } from "ext:deno_node/_fs/_fs_writev.ts";
import { fdatasyncPromise } from "ext:deno_node/_fs/_fs_fdatasync.ts";
import { fsyncPromise } from "ext:deno_node/_fs/_fs_fsync.ts";

interface WriteResult {
bytesWritten: number;
Expand Down Expand Up @@ -159,11 +161,11 @@ export class FileHandle extends EventEmitter {
}

datasync(): Promise<void> {
return fsCall(promises.fdatasync, this);
return fsCall(fdatasyncPromise, this);
}

sync(): Promise<void> {
return fsCall(promises.fsync, this);
return fsCall(fsyncPromise, this);
}

utimes(
Expand Down
8 changes: 8 additions & 0 deletions tests/node_compat/test/fixtures/baz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// deno-fmt-ignore-file
// deno-lint-ignore-file

// Copyright Joyent and Node contributors. All rights reserved. MIT license.
// Taken from Node 20.11.1
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.

module.exports = 'perhaps I work';

0 comments on commit 6e803d2

Please sign in to comment.