MCPcopy
hub / github.com/vitejs/vite / copyDir

Function copyDir

packages/vite/src/node/utils.ts:628–643  ·  view source on GitHub ↗
(srcDir: string, destDir: string)

Source from the content-addressed store, hash-verified

626// NOTE: we cannot use `fs.cpSync` because of a bug in Node.js (https://github.com/nodejs/node/issues/58768, https://github.com/nodejs/node/issues/59168)
627// also note that we should set `dereference: true` when we use `fs.cpSync`
628export function copyDir(srcDir: string, destDir: string): void {
629 fs.mkdirSync(destDir, { recursive: true })
630 for (const file of fs.readdirSync(srcDir)) {
631 const srcFile = path.resolve(srcDir, file)
632 if (srcFile === destDir) {
633 continue
634 }
635 const destFile = path.resolve(destDir, file)
636 const stat = fs.statSync(srcFile)
637 if (stat.isDirectory()) {
638 copyDir(srcFile, destFile)
639 } else {
640 fs.copyFileSync(srcFile, destFile)
641 }
642 }
643}
644
645export const ERR_SYMLINK_IN_RECURSIVE_READDIR =
646 'ERR_SYMLINK_IN_RECURSIVE_READDIR'

Callers 1

prepareOutDirFunction · 0.90

Calls 1

resolveMethod · 0.65

Tested by

no test coverage detected