Repository navigation
Update with pnpm when pnpm installed git-fi - #27
Merged
Merged
Conversation
`git fi --update` always ran `npm install -g`. For a copy installed with `pnpm add -g` that either fails, where npm isn't on PATH, or installs a second copy under npm's prefix while the pnpm copy `git fi` runs stays stale. pnpm writes `.modules.yaml` into every node_modules it manages and npm never does, so the update reads that marker beside the package rather than asking pnpm. Asking would follow corepack: the pnpm a directory's `packageManager` field selects need not be the one that installed git-fi, and in a yarn-pinned repo corepack refuses to run it. For the same reason pnpm runs from the temp directory, outside any project. A pnpm install with no pnpm on PATH gets a corepack hint rather than a fallback to npm, which would leave the second copy behind (UPDATE-05). What differs between package managers lives in a PackageManager subclass picked by PackageManager.detect, so supporting another one means adding a subclass, not more branches in updateSelf.
On a pnpm global install, `git fi --version` reported that a different git-fi was ahead of this one on PATH, naming pnpm's own launcher for the running copy. The launcher check read the entry point the way npm's shims write it, `node_modules/...` beside the launcher, but pnpm's names a path through its global directory, so it resolved to nothing and the copy looked shadowed. pnpm's launcher records its target as a `cmd-shim-target=` comment, which is now read first; otherwise the path is taken from after the shim's basedir variable, which covers both layouts. The advice in the notice now names pnpm's bin directory beside npm's (INSTALL-01).
Every install line in the docs named npm, although pnpm is a supported way to install git-fi and `git fi --update` now updates through it. Each npm line gains its pnpm equivalent, and the troubleshooting steps for a shadowed launcher name pnpm's bin directory beside npm's prefix.
Home's Get Started, Quick Start's Install, Troubleshooting, and the README each spelled out the install command, with npm first and pnpm as the alternative. Changing the default or the package name meant editing four places, and the Home section duplicated the Quick Start page its own Next Steps already pointed to. Quick Start's Install is now where a reader installs from. Home links to it from the lede, Troubleshooting links to it from the gem and --update sections, and the README points at the docs. The old-git section keeps its own block, since pinning @1.2.2 is a different package spec and a reader copying the unpinned command would install a release their git cannot run. Both blocks name only the package, in a fenced `install` block. A docsify plugin owns the per-manager commands and renders them as a pnpm | npm switch: pnpm shows first, the copy button copies the command on screen, and the reader's choice is remembered across pages and visits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
git fi --updatealways rannpm install -g. pnpm is the preferred package manager at Getty, and for a copy installed withpnpm add -gthe update either fails, where npm isn't onPATH, or installs a second copy under npm's prefix while the pnpm copy thatgit firuns stays stale. This PR ensures the update happens with whichever package manager installed the running copy, however pnpm itself got onto the machine (standalone, corepack, Homebrew).Detection reads pnpm's
.modules.yamlmarker beside the package instead of asking pnpm, since under corepackpnpm root -ganswers for whichever pnpm the current directory'spackageManagerfield selects. The PR also fixesgit fi --versionon a pnpm install, which wrongly reported that a different git-fi was ahead of it onPATH.Review guide
Three commits, one per concern: the update (
UPDATE-05), the launcher fix (INSTALL-01), and docs.Critical path
src/package-manager.ts— npm stays the fallback for anything pnpm doesn't claim (npx, the dev-trial link)src/package-manager.ts— only thenode_modulesdirectly holding the package counts, so npm's prefix nested inside a pnpm tree stays npm'ssrc/package-manager.ts— pnpm runs outside any project, so a repo'spackageManagerpin can't steer corepacksrc/which.ts— theINSTALL-01fix: read pnpm's recorded launcher targetWiring
src/update-check.tsTests
test/package-manager.test.ts— detection against pnpm 10 and 11+ layouts, npm layouts, and npm nested in pnpmtest/cli.test.ts—--updatethrough a pnpm-shaped install, run from a yarn-pinned projecttest/which.test.tsSpec & docs — skim
SPEC.md,STATUS.md,docs/quickstart.md,docs/troubleshooting.md