Expand description
Detect which Node.js package manager produced the layout in a
project root (npm, pnpm, yarn classic, or yarn-berry PnP).
The apply pipeline cares about this for two reasons:
-
pnpm:
node_modules/<pkg>is typically a symlink into the content-addressed global store. Patching the link target would corrupt every other project on the machine that points at the same store entry. The CoW guard incrate::patch::cow::break_hardlink_if_neededis what actually fixes this; this detector just lets the CLI surface a one-line “we detected pnpm, applied with CoW” notice so users understand the layout was handled. -
yarn-berry / Plug’n’Play: packages do not live on disk at all — they’re inside
.yarn/cache/<pkg>.zipand resolved via a custom Node loader (.pnp.cjs). The npm crawler can’t reach them, and rewriting bytes inside a zip is a totally different operation than rewriting bytes innode_modules/. The right move is to refuse with a clear error and point the user atyarn patch <pkg>.
Classic yarn (yarn.lock + a real node_modules/) behaves like
npm at the filesystem level, so no special handling is needed.
Enums§
- NpmPkg
Manager - Identified Node.js package manager / layout flavor.
Functions§
- detect_
npm_ pkg_ manager - Detect the package manager that produced the layout under
project_root. Inspection is purely path-based — no shell-outs, no parsing — so the detector is fast and side-effect-free.