Skip to content

fix: normalize bin metadata in getPaths - #189

Merged
martinrrm merged 1 commit into
release/v6from
martinrrm/normalize-bin-metadata-getpaths-v6
Oct 12, 2026
Merged

martinrrm merged 1 commit into
release/v6from
martinrrm/normalize-bin-metadata-getpaths-v6

Conversation

@martinrrm

Copy link
Copy Markdown
Contributor

Backport of #187 to the release/v6 line.

Summary

lib/link-bins.js already uses npm-normalize-package-bin before iterating over package bin entries. getPaths() derives the corresponding paths but operated on the package metadata directly, which could produce behavior inconsistent with bin creation for non-canonical entries.

This applies the same normalization in getPaths() so both APIs interpret bin metadata consistently. It normalizes a shallow copy to avoid modifying the caller's package object.

Why this line needs it

release/v6 is the line consumed by @npmcli/arborist@9.x / npm 11, which cannot move to bin-links@7 — v7 requires Node ^22.22.2 || ^24.15.0 || >=26.0.0, while npm 11 supports ^20.17.0 || >=22.9.0.

Notes

  • Clean cherry-pick of 7f9f97a; no conflicts and no source changes.
  • No dependency change needed: npm-normalize-package-bin@^5.0.0 is already a dependency here, and its normalization logic is byte-identical to the v6 used on main.

Testing

  • Full npm test suite passes, including 100% coverage on lib/get-paths.js
  • eslint and template-oss-check pass

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

## Summary

`lib/link-bins.js` already uses `npm-normalize-package-bin` before
iterating over package bin entries. `getPaths()` derives the
corresponding paths but previously operated on the package metadata
directly, which could produce behavior inconsistent with bin creation
for non-canonical entries.

This change applies the same normalization in `getPaths()` so both APIs
interpret bin metadata consistently. It normalizes a shallow copy to
avoid modifying the caller's package object.

The tests cover normalized bin names on POSIX and Windows and verify
that the original package metadata remains unchanged.

## Testing

- targeted `get-paths` tests
- ESLint

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3ff4d6b3-8027-46d4-9024-3bb9e4fc495c
(cherry picked from commit 7f9f97a)
@martinrrm
martinrrm requested a review from a team as a code owner September 28, 2026 22:51
@martinrrm
martinrrm merged commit e6c3b86 into release/v6 Oct 12, 2026
15 checks passed
@martinrrm
martinrrm deleted the martinrrm/normalize-bin-metadata-getpaths-v6 branch October 12, 2026 17:28
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
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.

3 participants