fix: correct package-manager detection and harden the CLI#1
Merged
Conversation
The monorepo traversal never actually walked up the directory tree — it only checked the starting directory, so running omnes from a sub-package fell back to npm instead of finding the root lockfile. Detection now walks to the filesystem root, honors a Corepack "packageManager" field, and matches the lockfile priority documented in the README (yarn before npm). Also fixes: --version reported a hardcoded "0.1.0" (now read from package.json), --help/--version print to stdout instead of stderr, the "Using" line shows the fully resolved command, and a missing package manager exits 127 as documented. Pure logic is extracted into src/lib.ts with unit tests covering traversal, Corepack, priority, and the npm arg transform. Adds Biome, typecheck/test/lint scripts, and a GitHub Actions CI workflow.
5 tasks
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.
What this does
Omnes advertised monorepo support — "run it from any sub-package and it finds the root lockfile" — but that never worked. The directory walk had an off-by-one bug that made it check only the directory you started in, so running
omnes installfrompackages/apisilently fell back to npm even when the root had apnpm-lock.yaml. This fixes the walk so detection works from anywhere in the tree, and adds support for the CorepackpackageManagerfield that modern repos pin.It also cleans up a handful of smaller correctness gaps and gives the project tests + CI so these don't regress.
Summary
detectPackageManager). The oldroot = dirname(startDir)sentinel exited the loop after one iteration. Verified from a subdirectory end-to-end.packageManagerfield is honored and takes precedence over a lockfile in the same directory; closest directory wins.--versionreads frompackage.jsoninstead of a hardcoded string that had drifted to0.1.0.--help/--versionprint to stdout (were on stderr, so--version | catproduced nothing).127as the API table documents (was1).Using:line shows the resolved command (Using bun: bun run dev).src/lib.ts;src/omnes.tsis a thin bin.typecheck/test/lint/formatscripts, GitHub Actions CI,.tldr/gitignored.0.1.3.Test Plan
bun run typecheck— cleanbun run lint(Biome) — cleanbun run test— 13/13 pass (traversal, Corepack, priority, npm arg transform)bun run build— succeeds, tests excluded fromdist/bun install --frozen-lockfile— no changes (CI-safe)--version→omnes v0.1.3on stdout; detection fromsrc/resolves bun via rootbun.lock