Skip to content

Update with pnpm when pnpm installed git-fi - #27

Merged
chris-peterson merged 4 commits into
mainfrom
update-with-pnpm
Nov 16, 2026
Merged

chris-peterson merged 4 commits into
mainfrom
update-with-pnpm

Conversation

@andyalm

@andyalm andyalm commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Context

git fi --update always ran npm install -g. pnpm is the preferred package manager at Getty, and for a copy installed with pnpm add -g the update either fails, where npm isn't on PATH, or installs a second copy under npm's prefix while the pnpm copy that git fi runs 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.yaml marker beside the package instead of asking pnpm, since under corepack pnpm root -g answers for whichever pnpm the current directory's packageManager field selects. The PR also fixes git fi --version on a pnpm install, which wrongly reported that a different git-fi was ahead of it on PATH.

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 the node_modules directly holding the package counts, so npm's prefix nested inside a pnpm tree stays npm's
  • src/package-manager.ts — pnpm runs outside any project, so a repo's packageManager pin can't steer corepack
  • src/which.ts — the INSTALL-01 fix: read pnpm's recorded launcher target

Wiring

Tests

Spec & docs — skim

`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.
@andyalm andyalm self-assigned this Nov 13, 2026
@andyalm andyalm added the enhancement New feature or request label Nov 13, 2026
@andyalm
andyalm added this pull request to stack #29 November 13, 2026 00:56
@andyalm
andyalm marked this pull request as ready for review November 13, 2026 01:02
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.
@chris-peterson
chris-peterson merged commit ca520f6 into main Nov 16, 2026
9 checks passed
@chris-peterson
chris-peterson deleted the update-with-pnpm branch November 16, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants