Skip to content

[Performance] Optimize copyDirectoryContents with glob cwd#7452

Closed
gonzaloriestra wants to merge 1 commit into
mainfrom
bolt/optimize-copy-directory-contents-3559203706858836990
Closed

[Performance] Optimize copyDirectoryContents with glob cwd#7452
gonzaloriestra wants to merge 1 commit into
mainfrom
bolt/optimize-copy-directory-contents-3559203706858836990

Conversation

@gonzaloriestra

Copy link
Copy Markdown
Contributor

What was improved

Optimized the copyDirectoryContents function in @shopify/cli-kit to be faster and more robust by using the cwd option in glob.

Why it was improved

The previous implementation fetched absolute paths and then used string replacement and regex to strip the source directory prefix for every item found. This is inefficient, especially for directories with many files, and can be brittle due to path separator differences. Using cwd allows the globbing engine to provide relative paths directly, which is faster and more reliable.

How to test your changes?

You can verify that directory copying still works correctly by running the existing unit tests:

cd packages/cli-kit
pnpm vitest run src/public/node/fs.test.ts

The tests copyDirectoryContents > copies the contents of source directory to destination directory and its variations confirm that files and nested directories are still copied as expected.


PR created automatically by Jules for task 3559203706858836990 started by @gonzaloriestra

Optimized `copyDirectoryContents` in `@shopify/cli-kit` by using the `cwd` option in `glob` to retrieve relative paths directly. This eliminates the need for manual absolute-to-relative path transformation using string replacement and regex on every file, which is more efficient and robust across different platforms.

Key changes:
- Updated `glob` call to use `{cwd: srcDir}`.
- Removed `item.replace(srcDir, '')` logic.
- Simplified path construction in the copy loop.
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant