feat(detector): implement Nodenv detection#7
Merged
Conversation
Mirrors the ASDF pattern (PATH binary + env var + ~/.nodenv fallback) since Nodenv and ASDF share a near-identical install layout. Filters the 'system' sentinel from 'nodenv versions' and strips the ' (set by <origin>)' annotation that asdf's output lacks. Mutation methods return ErrNodenvNotImplemented (Phase 4 work).
|
✔️ 4fd9baa - Conventional commits check succeeded. |
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.
Changes
internal/detector/nodenv.go(full implementation):Detect():platform.LookupManagerBinary("nodenv") != ""OR$NODENV_ROOTenv OR~/.nodenvon disk (ASDF pattern)Version():nodenv --version, strips literal"nodenv "prefix, first whitespace-separated token, optionalvprefix strippedListInstalled():nodenv versions, lines* <v>/<v>, the trailing(set by <origin>)on current-version lines is stripped before semver parse;systemsentinel filtered outnodenvRoot()helper:$NODENV_ROOT→~/.nodenv, mirrorsasdfDataDirErrNodenvNotImplementedsentinel (ASDF pattern)internal/detector/nodenv_test.go(24 mocked tests):parseNodenvVersion: standard, git-revision suffix (1.6.2-12-gabc1234),v-prefixed, whitespace, empty, whitespace-only, no-version-after-prefixparseNodenvInstalled: real output (with(set by ...)suffix), filterssystemsentinel, unsorted → sorted ascending, empty stdout, only blank lines, skips unparseable linesName,Version(success capturing command,v-prefixed, runShell error, parsing error),ListInstalled(success, empty stdout, runShell error)Detect: PATH-without-binary, dir-on-disk,$NODENV_ROOToverride, empty env falls through, binary-on-PATH Windows-safe vianodenv.exeMutationMethods_NotImplementedsentinel testnodenvRoothelper: env-precedence, home-fallback, empty-when-no-home, whitespace-only-env-falls-throughDesign notes
* <v>(current) line innodenv versionscarries a trailing(set by <origin>)annotation that asdf's output does NOT have. The parser strips everything from the first whitespace after the digits before handing tosemver.NewVersion— this is the only behavioral divergence fromparseASDFInstalled.systemsentinel is filtered explicitly (thesystemline is emitted iffnodenv-which nodesucceeds, i.e., there is a node on the system PATH outside Nodenv's managed versions — not a managed install).nodenvRoot()mirrorsasdfDataDir()(same env → home fallback, same whitespace handling) for consistency.strings.CutPrefix("nodenv ")inparseNodenvVersionso unexpected branding like"Nodenv v1.6.2"errors loudly rather than silently returning the wrong token.