mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 15:49:44 -05:00
fix(node): add cp
to fs/promises (#22263)
This commit is contained in:
parent
28576db10e
commit
428266c06a
2 changed files with 16 additions and 1 deletions
|
@ -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");
|
||||
},
|
||||
);
|
||||
|
|
|
@ -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…
Reference in a new issue