MCPcopy Create free account
hub / github.com/denoland/std / copy

Function copy

fs/copy.ts:306–333  ·  view source on GitHub ↗
(
  src: string | URL,
  dest: string | URL,
  options: CopyOptions = {},
)

Source from the content-addressed store, hash-verified

304 * last modification and access times to the ones of the original source files.
305 */
306export async function copy(
307 src: string | URL,
308 dest: string | URL,
309 options: CopyOptions = {},
310) {
311 src = resolve(toPathString(src));
312 dest = resolve(toPathString(dest));
313
314 if (src === dest) {
315 throw new Error("Source and destination cannot be the same");
316 }
317
318 const srcStat = await Deno.lstat(src);
319
320 if (srcStat.isDirectory && isSubdir(src, dest)) {
321 throw new Error(
322 `Cannot copy '${src}' to a subdirectory of itself: '${dest}'`,
323 );
324 }
325
326 if (srcStat.isSymlink) {
327 await copySymLink(src, dest, options);
328 } else if (srcStat.isDirectory) {
329 await copyDir(src, dest, options);
330 } else if (srcStat.isFile) {
331 await copyFile(src, dest, options);
332 }
333}
334
335/**
336 * Synchronously copy a file or directory (along with its contents), like

Callers 2

fnFunction · 0.90
copy_test.tsFile · 0.90

Calls 6

resolveFunction · 0.90
toPathStringFunction · 0.90
isSubdirFunction · 0.90
copySymLinkFunction · 0.85
copyDirFunction · 0.85
copyFileFunction · 0.70

Tested by

no test coverage detected