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(node): add cp to fs/promises #22263

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion cli/tests/unit_node/fs_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
readFileSync,
writeFileSync,
} from "node:fs";
import { constants as fsPromiseConstants } from "node:fs/promises";
import { constants as fsPromiseConstants, cp } from "node:fs/promises";
import { pathToAbsoluteFileUrl } from "../unit/test_util.ts";

Deno.test(
Expand Down Expand Up @@ -100,3 +100,17 @@ Deno.test(
assertEquals(constants, promises.constants);
},
);

Deno.test(
"[node/fs/promises cp] copy file",
async () => {
const src = mkdtempSync(join(tmpdir(), "foo-")) + "/test.txt";
const dest = mkdtempSync(join(tmpdir(), "foo-")) + "/test.txt";
writeFileSync(src, "Hello");

await cp(src, dest);

const dataRead = readFileSync(dest, "utf8");
assert(dataRead === "Hello");
},
);
1 change: 1 addition & 0 deletions ext/node/polyfills/fs/promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ export const writeFile = fsPromises.writeFile;
export const appendFile = fsPromises.appendFile;
export const readFile = fsPromises.readFile;
export const watch = fsPromises.watch;
export const cp = fsPromises.cp;

export default fsPromises;
Loading