[Refactor] Simplify copyDirectoryContents implementation#7433
[Refactor] Simplify copyDirectoryContents implementation#7433gonzaloriestra wants to merge 1 commit intomainfrom
Conversation
|
👋 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. |
Replaced manual glob and loop with a single fsCopy call from fs-extra. This improves performance, is more robust against EMFILE errors on large directories, and significantly simplifies the code while maintaining the same behavior. Made-with: Cursor
e8d9c22 to
dad8554
Compare
WHY are these changes introduced?
copyDirectoryContentsinpackages/cli-kit/src/public/node/fs.tsreimplemented directory copying by hand: it created the destination, ran aglobover the source tree, and fanned out onecopyFileper match throughPromise.all. That extra logic is harder to reason about and can hitEMFILE("too many open files") on large trees because every file is opened concurrently.fs-extra'sfsCopyalready handles directory creation, recursion, and back-pressure correctly.WHAT is this pull request doing?
glob+Promise.all/copyFileloop incopyDirectoryContentswith a singlefsCopy(srcDir, destDir)call.mkdirfor the destination (handled byfsCopy).How to test your changes?
copyDirectoryContentsis exercised by theinclude_assetsbuild step for UI extensions when thesourceis a directory. Build any app whose extension declares aninclude_assetsentry pointing at a directory and confirm the contents are copied recursively:After the build, verify under the extension's output directory (
<path-to-app>/dist/<extension>/...) that:EMFILE/ENOENTerrors.Negative path — make sure the original error message is preserved when the source is missing. Run from the repo root against the built bundle:
Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add