Commit 38186cc
fix(npm): create shims for all bin entries during global npm install (#32607)
Fixes #26133
When running `deno install -g npm:pyright`, only the first bin entry
(`pyright`) got a shim. The second entry (`pyright-langserver`) was
missing. This affects any npm package with multiple `bin` entries in
`package.json`.
### Changes
- **Name resolution for multi-bin packages** —
`resolve_name_from_npm_package_info()` now returns the bin name matching
the package name (or unscoped name for `@scope/pkg`) when multiple
entries exist, instead of returning `None`
- **Extra bin entry resolution** — `resolve_all_bin_entries_from_npm()`
on `BinNameResolver` returns all `(name, script_path)` pairs;
`BinaryNameAndUrl::resolve()` returns extra entries with proper
`npm:pkg@version/script_path` URLs
- **Shared config directory** — Extra bin shims reference the primary
entry's config dir via a `config_name` field on `BinaryNameAndUrl`, so
all shims from the same package share one `.pkg/` config directory with
`deno.json`, `package.json`, and `node_modules`
- **Install** — `install_global()` creates shims for all entries and
persists extra names to `extra_bin_entries.json` in the config dir
- **Rollback on failure** — If an extra bin shim fails to install (e.g.,
name conflict without `-f`), the primary shim and any already-created
extra shims are cleaned up to avoid partial installs
- **Uninstall** — `uninstall()` reads `extra_bin_entries.json` and
removes all associated shims
- **Skipped when `--name` is provided** — explicit naming implies
single-entry intent
### Test coverage
- New `@denotest/multi-bin` test package with two bin entries
- Spec test: install creates both shims, both execute correctly,
uninstall removes both
- Unit tests for multi-bin name inference and entry resolution
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bartlomieju <13602871+bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 49a9e13 commit 38186cc
11 files changed
Lines changed: 388 additions & 25 deletions
File tree
- cli/tools/installer
- tests
- registry/npm/@denotest/multi-bin/1.0.0
- specs/install/global/npm_multiple_bins
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
109 | 108 | | |
110 | 109 | | |
111 | 110 | | |
112 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | | - | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | 123 | | |
131 | 124 | | |
132 | 125 | | |
133 | 126 | | |
134 | 127 | | |
135 | | - | |
136 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
137 | 135 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
143 | 178 | | |
144 | 179 | | |
145 | 180 | | |
146 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
147 | 192 | | |
148 | 193 | | |
149 | 194 | | |
| |||
313 | 358 | | |
314 | 359 | | |
315 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
316 | 450 | | |
0 commit comments