Repository navigation
Commit 0c33947
authored
fix(reify): report added count for fresh linked installs (#9661)
Under `install-strategy=linked`, a fresh `npm install` that actually
creates `.store` entries and symlinks printed `up to date, audited N
packages` instead of `added N packages`, misleading users and CI into
thinking nothing changed.
`reify-output` counts adds with `actualTree.inventory.has(d.ideal)`.
Under the linked strategy the diff's `ideal` nodes belong to the
isolated store tree (locations under
`node_modules/.store/<key>/node_modules/<name>`), while the `actualTree`
returned after reify is the logical hoisted-layout tree. The two never
share node identity, so the lookup always failed and `added` stayed `0`.
The ADD branch now also counts a node when it is a real store package
node (`isInStore && !isLink`), which maps 1:1 to a hoisted package add.
This excludes the internal store symlinks and the top-level consumer
symlink, so the count matches hoisted for registry dependencies
(verified: `minimatch` 4/4, `rimraf` 12/12, `express` 69/69).
Omitted/incompatible optional deps have no store entry and are still not
counted, and hoisted behavior is unchanged.
Known limitations (tracked separately): workspace and `file:`/`npm link`
additions are represented as links rather than store nodes under linked,
so they are not yet counted here — counting them is entangled with the
self-link bug (#9398) and the undeclared-workspaces bug (#9618). The
`--json` `add[].path` for a counted store package points to its `.store`
realpath rather than a logical `node_modules/<name>` path.
## References
Fixes #96231 parent 541c286 commit 0c33947
3 files changed
Lines changed: 26 additions & 1 deletion
File tree
- lib/utils
- tap-snapshots/test/lib/utils
- test/lib/utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
394 | 413 | | |
395 | 414 | | |
396 | 415 | | |
| |||
0 commit comments