diff --git a/packages/cli-kit/src/public/node/fs.ts b/packages/cli-kit/src/public/node/fs.ts index 698edd4499..00ce8ff9ae 100644 --- a/packages/cli-kit/src/public/node/fs.ts +++ b/packages/cli-kit/src/public/node/fs.ts @@ -728,16 +728,13 @@ export async function copyDirectoryContents(srcDir: string, destDir: string): Pr } // Get all files and directories in the source directory - const items = await glob(joinPath(srcDir, '**/*')) - - const filesToCopy = [] - - for (const item of items) { - const relativePath = item.replace(srcDir, '').replace(/^[/\\]/, '') - const destPath = joinPath(destDir, relativePath) - - filesToCopy.push(copyFile(item, destPath)) - } - - await Promise.all(filesToCopy) + const relativePaths = await glob('**/*', {cwd: srcDir}) + + await Promise.all( + relativePaths.map((relativePath) => { + const srcPath = joinPath(srcDir, relativePath) + const destPath = joinPath(destDir, relativePath) + return copyFile(srcPath, destPath) + }), + ) }