Resolve copy paths relative to src in DomStack constructor#251
Resolve copy paths relative to src in DomStack constructor#251
Conversation
Relative copy paths like 'images' now resolve against the parent directory of src rather than process.cwd(), matching what the CLI does. Resolved paths are stored in this.opts.copy so all downstream consumers (buildCopy, watch watchers) use the same absolute paths. Closes #234
Coverage Report for CI Build 24619571843Coverage increased (+0.003%) to 91.472%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
Fixes programmatic DomStack usage so relative copy paths are normalized consistently (stored as absolute paths) based on the src location rather than the process working directory.
Changes:
- Resolve
opts.copyentries to absolute paths in theDomStackconstructor. - Persist resolved copy paths back onto
this.opts.copyso downstream copy steps/watchers consume consistent absolute paths. - Simplify dest-containment validation to operate on already-resolved copy paths.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dirname(resolve(src)) is incorrect when src is '.' (the common default), as it resolves to the parent of cwd rather than cwd itself. Using plain resolve(dir) — which is equivalent to resolve(cwd, dir) — matches exactly what the CLI does before passing paths to the constructor.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Verifies that relative copy paths are resolved to absolute paths (matching process.cwd()), that already-absolute paths are preserved, and that mixed relative+absolute arrays are both resolved correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Relative
copypaths passed to theDomStackconstructor (e.g.,copy: ['images', 'media']) now resolve againstdirname(resolve(src))instead ofprocess.cwd(), matching what the CLI does before passing arguments to the constructor.The resolved paths are stored in
this.opts.copyso all downstream consumers (thebuildCopystep and the cpx watch watchers) receive consistent absolute paths regardless of where the process is launched from.Before this fix, programmatic callers had to pre-resolve copy paths themselves:
Closes #234