diff --git a/src/util/copy.ts b/src/util/copy.ts index ddb1842c5..e51f8ddc8 100644 --- a/src/util/copy.ts +++ b/src/util/copy.ts @@ -79,7 +79,15 @@ export const copyEntries = async ( */ const copyFileGracefully = async (src: string, dest: string): Promise => { try { - await fs.copyFile(src, dest, fs.constants.COPYFILE_EXCL); + await fs.copyFile( + src, + dest, + // COPYFILE_FICLONE: Copy the file using copy-on-write semantics, so that + // the copy takes constant time and space. This is a noop currently + // on some platforms, but it's a nice optimization to have. + // See https://github.com/libuv/libuv/issues/2936 for macos support. + fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE, + ); } catch (error) { const {code} = error as {code: string}; if (code === /* does not exist */ 'ENOENT') {