MCPcopy
hub / github.com/vercel/next.js / copy

Function copy

scripts/patch-next.ts:96–128  ·  view source on GitHub ↗
(src: string, dst: string)

Source from the content-addressed store, hash-verified

94}
95
96async function copy(src: string, dst: string): Promise<void> {
97 const realDst = realPathIfAny(dst)
98
99 if (!realDst) {
100 WARN(`[x] Destination path ${dst} does not exist. Skipping copy.`)
101 return
102 }
103
104 if (realDst && realDst === src) {
105 WARN(
106 `[x] Source and destination paths are the same: ${src}. Skipping copy.`
107 )
108 return
109 }
110
111 if (!fs.existsSync(src)) {
112 WARN(`[x] Source path ${src} does not exist. Skipping copy.`)
113 return
114 }
115
116 const files = await packageFiles(src)
117 DEBUG(`[x] Found ${files.length} files to copy from ${src}`)
118
119 for (const file of files) {
120 const srcFile = path.join(src, file)
121 const dstFile = path.join(realDst, file)
122
123 DEBUG(`Copying ${srcFile} to ${dstFile}`)
124 fs.cpSync(srcFile, dstFile, {
125 recursive: true,
126 })
127 }
128}
129
130// --- Main execution ---
131async function main(): Promise<void> {

Callers 1

mainFunction · 0.70

Calls 5

WARNFunction · 0.85
packageFilesFunction · 0.85
DEBUGFunction · 0.85
realPathIfAnyFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected