Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/cli-kit/src/public/node/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,15 +728,16 @@ export async function copyDirectoryContents(srcDir: string, destDir: string): Pr
}

// Get all files and directories in the source directory
const items = await glob(joinPath(srcDir, '**/*'))
// Optimization: Use `cwd` to get relative paths directly from glob.
// This avoids expensive absolute path manipulation and prefix stripping.
const items = await glob('**/*', {cwd: srcDir})

const filesToCopy = []

for (const item of items) {
const relativePath = item.replace(srcDir, '').replace(/^[/\\]/, '')
const destPath = joinPath(destDir, relativePath)
const destPath = joinPath(destDir, item)

filesToCopy.push(copyFile(item, destPath))
filesToCopy.push(copyFile(joinPath(srcDir, item), destPath))
}

await Promise.all(filesToCopy)
Expand Down
Loading