Skip to content

Commit

Permalink
fix(node/fs): promises not exporting fs constants
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Jan 19, 2024
1 parent c62615b commit f1f1143
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
24 changes: 22 additions & 2 deletions cli/tests/unit_node/fs_test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

import { assert, assertThrows } from "../../../test_util/std/assert/mod.ts";
import {
assert,
assertEquals,
assertThrows,
} from "../../../test_util/std/assert/mod.ts";
import { join } from "node:path";
import { tmpdir } from "node:os";
import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
import {
constants,
existsSync,
mkdtempSync,
promises,
readFileSync,
writeFileSync,
} from "node:fs";
import { constants as fsPromiseConstants } from "node:fs/promises";
import { pathToAbsoluteFileUrl } from "../unit/test_util.ts";

Deno.test(
Expand Down Expand Up @@ -80,3 +92,11 @@ Deno.test(
assert(!existsSync("bad_filename"));
},
);

Deno.test(
"[node/fs/promises constants] is the same as from node:fs",
() => {
assertEquals(constants, fsPromiseConstants);
assertEquals(constants, promises.constants);
},
);
1 change: 1 addition & 0 deletions ext/node/polyfills/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const {

const promises = {
access: accessPromise,
constants,
copyFile: copyFilePromise,
cp: cpPromise,
open: openPromise,
Expand Down
1 change: 1 addition & 0 deletions ext/node/polyfills/fs/promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { promises as fsPromises } from "node:fs";

export const access = fsPromises.access;
export const constants = fsPromises.constants;
export const copyFile = fsPromises.copyFile;
export const open = fsPromises.open;
export const opendir = fsPromises.opendir;
Expand Down

0 comments on commit f1f1143

Please sign in to comment.