Repository navigation
Commit b73b080
* Start fix for #1804
Assisted-by: Claude Code:claude-opus-5-5
* Keep CRLF shebang on bins npm didn't link
Since #1792, apply and rollback treated every file a package lists as a
bin as one npm had rewritten to an LF shebang at install. npm only does
that for bins it links. With bin-links=false (--no-bin-links), or for a
directories.bin file of a package installed from a tarball or folder,
the installed file keeps its CRLF shebang, so apply wrote bytes that
matched neither the patch nor a fresh install, and rollback no longer
restored the installed file byte for byte.
A listed bin now counts as npm's form only when npm linked it: a
.bin/<name> entry in a node_modules the package sits under (a symlink
must point at this file), a pnpm dependent's .bin entry, or a global
prefix bin or .cmd shim. Bins npm did link, including ones an older
release left with a CRLF shebang (#1791), are still repaired.
Fixes #1804
Assisted-by: Claude Code:claude-opus-5-5
* Look for npm's bin link only where npm puts it
npm links a package's bins into the .bin folder of the node_modules the
package sits in, so a nested copy is no longer taken as linked because
the top-level copy of the same package has a .bin entry. Packages in a
virtual store (pnpm, npm's linked strategy, vlt, Bun) get their bins
linked into each dependent instead, so there the bin listing alone
still counts, as it did before.
Also check the on-disk shebang before the link, which is cheaper, and
read a bin key with a trailing slash the way npm does.
Refs #1804
Assisted-by: Claude Code:claude-opus-5-5
* Only trust a bin shim that runs this file
A regular file that merely had a bin's name, such as a project's own
<name>.cmd or a lib/../bin script, counted as npm's link, so a bin npm
never linked could still be rewritten with an LF shebang. A shim now
has to name this file's path below node_modules, as npm's and pnpm's
shims do; a symlink still has to resolve to it.
Copies in a store npm doesn't lay out (outside any node_modules, as in
Yarn's pnpmStoreFolder, or in a name@version entry of a relocated pnpm
virtualStoreDir) keep taking the bin listing as the link, as before.
Refs #1804
Assisted-by: Claude Code:claude-opus-5-5
* Match a bin shim's path on whole segments
A shim for another package whose folder name ends the same way, such as
a-crlfbin/cli.js, or a sibling file like cli.json, counted as running
this package's bin. The shim now has to name the path as whole
segments.
Refs #1804
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: socket-patch-agent <noreply@anthropic.com>
1 parent 34f13e0 commit b73b080
4 files changed
Lines changed: 605 additions & 105 deletions
File tree
- crates
- socket-patch-cli/tests
- socket-patch-core/src/patch
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1174 | 1174 | | |
1175 | 1175 | | |
1176 | 1176 | | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
1177 | 1192 | | |
1178 | 1193 | | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
1186 | 1198 | | |
1187 | 1199 | | |
1188 | 1200 | | |
| |||
1196 | 1208 | | |
1197 | 1209 | | |
1198 | 1210 | | |
1199 | | - | |
1200 | | - | |
1201 | | - | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
1206 | | - | |
1207 | | - | |
1208 | | - | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
1209 | 1220 | | |
1210 | 1221 | | |
1211 | 1222 | | |
1212 | 1223 | | |
1213 | 1224 | | |
1214 | | - | |
1215 | | - | |
1216 | 1225 | | |
1217 | 1226 | | |
1218 | 1227 | | |
| |||
1223 | 1232 | | |
1224 | 1233 | | |
1225 | 1234 | | |
1226 | | - | |
| 1235 | + | |
1227 | 1236 | | |
1228 | 1237 | | |
1229 | 1238 | | |
| |||
1345 | 1354 | | |
1346 | 1355 | | |
1347 | 1356 | | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4180 | 4180 | | |
4181 | 4181 | | |
4182 | 4182 | | |
4183 | | - | |
| 4183 | + | |
| 4184 | + | |
| 4185 | + | |
| 4186 | + | |
| 4187 | + | |
| 4188 | + | |
| 4189 | + | |
| 4190 | + | |
| 4191 | + | |
| 4192 | + | |
4184 | 4193 | | |
4185 | | - | |
| 4194 | + | |
4186 | 4195 | | |
4187 | 4196 | | |
4188 | 4197 | | |
4189 | 4198 | | |
4190 | | - | |
| 4199 | + | |
4191 | 4200 | | |
4192 | 4201 | | |
4193 | 4202 | | |
4194 | 4203 | | |
4195 | 4204 | | |
4196 | 4205 | | |
4197 | | - | |
| 4206 | + | |
4198 | 4207 | | |
4199 | 4208 | | |
4200 | 4209 | | |
| |||
4205 | 4214 | | |
4206 | 4215 | | |
4207 | 4216 | | |
4208 | | - | |
| 4217 | + | |
4209 | 4218 | | |
4210 | 4219 | | |
4211 | 4220 | | |
| |||
4214 | 4223 | | |
4215 | 4224 | | |
4216 | 4225 | | |
4217 | | - | |
| 4226 | + | |
4218 | 4227 | | |
4219 | 4228 | | |
4220 | 4229 | | |
| |||
4239 | 4248 | | |
4240 | 4249 | | |
4241 | 4250 | | |
4242 | | - | |
4243 | | - | |
| 4251 | + | |
| 4252 | + | |
| 4253 | + | |
| 4254 | + | |
| 4255 | + | |
| 4256 | + | |
| 4257 | + | |
| 4258 | + | |
| 4259 | + | |
| 4260 | + | |
| 4261 | + | |
4244 | 4262 | | |
4245 | 4263 | | |
4246 | | - | |
| 4264 | + | |
4247 | 4265 | | |
4248 | 4266 | | |
4249 | 4267 | | |
4250 | | - | |
4251 | | - | |
4252 | | - | |
4253 | | - | |
4254 | | - | |
4255 | | - | |
4256 | | - | |
| 4268 | + | |
| 4269 | + | |
4257 | 4270 | | |
4258 | 4271 | | |
4259 | 4272 | | |
4260 | | - | |
| 4273 | + | |
4261 | 4274 | | |
4262 | 4275 | | |
4263 | 4276 | | |
| |||
4267 | 4280 | | |
4268 | 4281 | | |
4269 | 4282 | | |
4270 | | - | |
| 4283 | + | |
4271 | 4284 | | |
4272 | 4285 | | |
4273 | 4286 | | |
4274 | 4287 | | |
4275 | 4288 | | |
| 4289 | + | |
| 4290 | + | |
| 4291 | + | |
| 4292 | + | |
| 4293 | + | |
| 4294 | + | |
| 4295 | + | |
| 4296 | + | |
| 4297 | + | |
| 4298 | + | |
| 4299 | + | |
| 4300 | + | |
| 4301 | + | |
| 4302 | + | |
| 4303 | + | |
| 4304 | + | |
| 4305 | + | |
| 4306 | + | |
| 4307 | + | |
| 4308 | + | |
| 4309 | + | |
| 4310 | + | |
| 4311 | + | |
| 4312 | + | |
| 4313 | + | |
| 4314 | + | |
| 4315 | + | |
| 4316 | + | |
| 4317 | + | |
| 4318 | + | |
| 4319 | + | |
| 4320 | + | |
| 4321 | + | |
| 4322 | + | |
| 4323 | + | |
| 4324 | + | |
| 4325 | + | |
| 4326 | + | |
| 4327 | + | |
| 4328 | + | |
| 4329 | + | |
| 4330 | + | |
| 4331 | + | |
| 4332 | + | |
| 4333 | + | |
| 4334 | + | |
| 4335 | + | |
| 4336 | + | |
| 4337 | + | |
| 4338 | + | |
| 4339 | + | |
| 4340 | + | |
| 4341 | + | |
| 4342 | + | |
| 4343 | + | |
| 4344 | + | |
| 4345 | + | |
| 4346 | + | |
| 4347 | + | |
| 4348 | + | |
| 4349 | + | |
| 4350 | + | |
| 4351 | + | |
| 4352 | + | |
| 4353 | + | |
| 4354 | + | |
| 4355 | + | |
| 4356 | + | |
| 4357 | + | |
| 4358 | + | |
| 4359 | + | |
| 4360 | + | |
| 4361 | + | |
| 4362 | + | |
| 4363 | + | |
| 4364 | + | |
| 4365 | + | |
| 4366 | + | |
| 4367 | + | |
| 4368 | + | |
| 4369 | + | |
| 4370 | + | |
| 4371 | + | |
| 4372 | + | |
| 4373 | + | |
| 4374 | + | |
| 4375 | + | |
| 4376 | + | |
4276 | 4377 | | |
4277 | 4378 | | |
4278 | 4379 | | |
| |||
0 commit comments