Skip to content

Resolve copy paths relative to src in DomStack constructor#251

Open
bcomnes wants to merge 5 commits intomasterfrom
fix/copy-path-resolution
Open

Resolve copy paths relative to src in DomStack constructor#251
bcomnes wants to merge 5 commits intomasterfrom
fix/copy-path-resolution

Conversation

@bcomnes
Copy link
Copy Markdown
Owner

@bcomnes bcomnes commented Apr 18, 2026

Relative copy paths passed to the DomStack constructor (e.g., copy: ['images', 'media']) now resolve against dirname(resolve(src)) instead of process.cwd(), matching what the CLI does before passing arguments to the constructor.

The resolved paths are stored in this.opts.copy so all downstream consumers (the buildCopy step 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:

// Before: required manual resolve to avoid silent failures
new DomStack('src', 'public', { copy: [resolve('images')] })

// After: relative paths just work
new DomStack('src', 'public', { copy: ['images'] })

Closes #234

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
Copilot AI review requested due to automatic review settings April 18, 2026 18:44
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 18, 2026

Coverage Report for CI Build 24619571843

Coverage increased (+0.003%) to 91.472%

Details

  • Coverage increased (+0.003%) from the base build.
  • Patch coverage: 4 of 4 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4070
Covered Lines: 3804
Line Coverage: 93.46%
Relevant Branches: 644
Covered Branches: 508
Branch Coverage: 78.88%
Branches in Coverage %: Yes
Coverage Strength: 74.35 hits per line

💛 - Coveralls

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.copy entries to absolute paths in the DomStack constructor.
  • Persist resolved copy paths back onto this.opts.copy so 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.

Comment thread index.js Outdated
Comment thread index.js Outdated
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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread test-cases/constructor-copy-paths/index.test.js Outdated
Comment thread test-cases/constructor-copy-paths/index.test.js Outdated
bcomnes and others added 2 commits April 18, 2026 19:49
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Programmatic API needs better support for testing and dry-run builds

3 participants