[Refactor] Use robust path handling in copyDirectoryContents#7445
[Refactor] Use robust path handling in copyDirectoryContents#7445gonzaloriestra wants to merge 1 commit intomainfrom
Conversation
Refactored `copyDirectoryContents` in `@shopify/cli-kit` to use the `cwd` option in `glob`, which provides relative paths directly from the filesystem. This eliminates fragile manual string replacement for relative path calculation. Additionally, simplified the implementation by using `.map()` with `Promise.all()` instead of an imperative `for...of` loop.
Summary of changes:
- Replaced `glob(joinPath(srcDir, '**/*'))` with `glob('**/*', {cwd: srcDir})`.
- Replaced manual path string manipulation with robust `joinPath` calls.
- Simplified parallel task execution using `.map()`.
- Added learning to `.jules/refactor.md`.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Description
Refactored
copyDirectoryContentsinpackages/cli-kit/src/public/node/fs.tsto improve robust path handling and simplify parallel task execution.Changes
copyDirectoryContentsto use thecwdoption inglob..map()call wrapped inPromise.all()..jules/refactor.md.How to test your changes?
Run the following command to verify that the refactored code still passes its unit tests:
pnpm --filter @shopify/cli-kit vitest run src/public/node/fs.test.tsPR created automatically by Jules for task 8140256861223159334 started by @gonzaloriestra