| … | … | @@ -499,15 +499,35 @@ module.exports = class HyperSync extends ReadyResource { |
| 499 | 499 | if (this._remoteHelperDir !== undefined) return this._remoteHelperDir; |
| 500 | 500 | this._remoteHelperDir = null; |
| 501 | 501 | try { |
| 502 | | // git-remote-punch sits as a SIBLING of hyper-sync — in the dev tree |
| 503 | | // (hyper-fleeky/{hyper-sync,git-remote-punch}) and when flattened into |
| 504 | | // node_modules (hoisted next to us). Also check the nested layout. |
| 505 | | const candidates = [ |
| 506 | | path.join(__dirname, '..', 'git-remote-punch', 'bin', 'git-remote-punch'), |
| 507 | | path.join(__dirname, 'node_modules', 'git-remote-punch', 'bin', 'git-remote-punch') |
| 508 | | ]; |
| 502 | // Resolve git-remote-punch's bin. ORDER MATTERS: prefer the MODULE-RESOLVED |
| 503 | // (hoisted top-level) copy. In content-addressed pgh bundles, hyper-sync's |
| 504 | // NESTED node_modules/git-remote-punch is deduped/pruned — its `bin/` can be |
| 505 | // ABSENT while the package dir lingers, so a shim pointing at that missing |
| 506 | // file makes bare abort (SIGABRT) on EVERY fetch (org joiners then get refs |
| 507 | // but zero objects). The hoisted top-level copy is the complete one. |
| 508 | const candidates = []; |
| 509 | try { |
| 510 | // Follows node_modules resolution to the hoisted top-level copy. |
| 511 | // (Available under Node; may be absent under bare — hence the walk below.) |
| 512 | const pkg = require.resolve('git-remote-punch/package.json'); |
| 513 | candidates.push(path.join(path.dirname(pkg), 'bin', 'git-remote-punch')); |
| 514 | } catch {} |
| 515 | // bare-safe fallback: walk ancestors for a HOISTED node_modules/git-remote-punch |
| 516 | // (the top-level, COMPLETE copy). Does not rely on require.resolve. |
| 517 | for (let d = __dirname, prev = null; d !== prev; prev = d, d = path.dirname(d)) { |
| 518 | candidates.push(path.join(d, 'node_modules', 'git-remote-punch', 'bin', 'git-remote-punch')); |
| 519 | } |
| 520 | // Dev tree (sibling) + immediate-nested fallbacks. |
| 521 | candidates.push(path.join(__dirname, '..', 'git-remote-punch', 'bin', 'git-remote-punch')); |
| 522 | candidates.push(path.join(__dirname, 'node_modules', 'git-remote-punch', 'bin', 'git-remote-punch')); |
| 523 | |
| 509 | 524 | let helperBin = null; |
| 510 | | for (const c of candidates) { try { if (fs.existsSync(c)) { helperBin = c; break; } } catch {} } |
| 525 | for (const c of candidates) { |
| 526 | // Verify the actual BIN FILE exists (isFile) — a pruned package dir must |
| 527 | // NOT be selected, or we shim a missing path and crash. Fall through, and |
| 528 | // finally to null (git uses whatever git-remote-punch is already on PATH). |
| 529 | try { if (fs.existsSync(c) && fs.statSync(c).isFile()) { helperBin = c; break; } } catch {} |
| 530 | } |
| 511 | 531 | if (!helperBin) return null; |
| 512 | 532 | |
| 513 | 533 | // git-remote-punch is `#!/usr/bin/env bare`, so the shim runs it under the |