Skip to content

Commit 0cb7325

Browse files
committed
feat(fs): support for copyFile methods in fs/promises
Signed-off-by: Sam Gammon <sam@elide.ventures>
1 parent 8b04007 commit 0cb7325

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

elide/runtime/js/modules/fs/promises/fs-async.ts

+18
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ const constants = {
3737
R_OK: 4,
3838
W_OK: 2,
3939
X_OK: 1,
40+
COPYFILE_EXCL: 1,
41+
COPYFILE_FICLONE: 2,
42+
COPYFILE_FICLONE_FORCE: 4,
4043
};
4144

4245
/**
@@ -97,10 +100,25 @@ export function mkdir(path: string | Buffer | URL, options: { recursive: boolean
97100
return internalsAccessor().mkdir(path, options);
98101
}
99102

103+
/**
104+
* Copy a file
105+
*
106+
* Asynchronously copies one file path to another, optionally with certain mode flags.
107+
*
108+
* @param src Source path to copy from
109+
* @param dest Destination path to copy to
110+
* @param mode Mode to copy with
111+
* @returns A promise that resolves when the file is written
112+
*/
113+
export function copyFile(src: string | Buffer | URL, dest: string | Buffer | URL, mode?: number): Promise<void> {
114+
return internalsAccessor().copyFile(src, dest, mode || 0);
115+
}
116+
100117
export default {
101118
access,
102119
constants,
103120
readFile,
104121
writeFile,
122+
copyFile,
105123
mkdir,
106124
};

0 commit comments

Comments
 (0)