mirror of
https://github.com/denoland/deno
synced 2024-08-28 20:39:51 +00:00
fix(node): add cp
to fs/promises (#22263)
This commit is contained in:
parent
28576db10e
commit
428266c06a
|
@ -15,7 +15,7 @@ import {
|
||||||
readFileSync,
|
readFileSync,
|
||||||
writeFileSync,
|
writeFileSync,
|
||||||
} from "node:fs";
|
} 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";
|
import { pathToAbsoluteFileUrl } from "../unit/test_util.ts";
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
|
@ -100,3 +100,17 @@ Deno.test(
|
||||||
assertEquals(constants, promises.constants);
|
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 appendFile = fsPromises.appendFile;
|
||||||
export const readFile = fsPromises.readFile;
|
export const readFile = fsPromises.readFile;
|
||||||
export const watch = fsPromises.watch;
|
export const watch = fsPromises.watch;
|
||||||
|
export const cp = fsPromises.cp;
|
||||||
|
|
||||||
export default fsPromises;
|
export default fsPromises;
|
||||||
|
|
Loading…
Reference in a new issue