1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(node): add cp to fs/promises (#22263)

This commit is contained in:
Divy Srivastava 2024-02-06 12:32:58 +05:30 committed by GitHub
parent 28576db10e
commit 428266c06a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -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(
@ -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");
},
);

View file

@ -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;