feat(detector): implement ASDF detection#4
Merged
Conversation
added 2 commits
June 29, 2026 17:13
Adds the asdf-vm manager (4/8) to the detector registry. ASDF is a
true binary (unlike NVM), so detection follows the same pattern as
FNM/Volta: a no-subprocess Detect() probe plus a runShell-backed
Version() and ListInstalled().
Detection strategy (any of):
1. `asdf` on PATH (via platform.LookupManagerBinary)
2. $ASDF_DATA_DIR env var is set
3. ~/.asdf directory exists on disk
Implementation notes:
- Version() runs `asdf version` (urfave/cli style, not --version)
and strips an optional 'v' prefix defensively.
- ListInstalled() runs `asdf list nodejs` and parses the
two-space-indented lines, where the current version is marked
with ' *'. Skips the 'No compatible versions installed' message
rather than aborting the parse.
- asdfDataDir() respects $ASDF_DATA_DIR (the data dir override)
before falling back to $HOME/.asdf, using the homeDir seam
already added by Volta for cross-platform test isolation.
- Mutation methods (Install, Uninstall, Use, SetDefault,
GlobalNpmPrefix) return ErrASDFNotImplemented — the same
sentinel pattern used by other Phase-1 managers.
Tests: 19 mocked tests covering parseASDFVersion (5), parseASDFInstalled
(6), the four Detect() branches (4), method-level coverage for
Name/Version/ListInstalled (7), and the not-implemented stubs (1).
TestASDF_DoesNotInvokeRunShellOnDetect explicitly verifies that
Detect() never spawns a subprocess on any of its happy paths.
- Replace 'Defence' with 'Defense' to satisfy the misspell linter rule. - Use platform-correct binary name (asdf.exe on Windows, asdf elsewhere) so the stub binary is found by exec.LookPath on Windows. - Replace PATH with a single entry pointing at the stub dir, rather than prepending — prevents a pre-existing asdf on the CI runner's PATH (notably the GitHub Actions Windows image) from shadowing the stub.
|
✔️ f684001...40ca167 - 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.
Summary
Adds ASDF (4/8) to the node-version-updater detector registry. ASDF is a true binary (unlike NVM), so detection follows the same pattern as FNM/Volta: a no-subprocess
Detect()probe plus arunShell-backedVersion()andListInstalled().Detection strategy
Detect()returns true when any of:asdfis onPATH(viaplatform.LookupManagerBinary)$ASDF_DATA_DIRenv var is set~/.asdfdirectory exists on diskAll three branches are pure-PATH/on-disk checks — no subprocesses.
TestASDF_DoesNotInvokeRunShellOnDetectenforces this with at.Fatalfif any branch reachesrunShell.Implementation
Version()— runsasdf version(urfave/cli style, not--version) and strips an optionalvprefix defensively.ListInstalled()— runsasdf list nodejsand parses the two-space-indented lines, where the current version is marked with*. Skips theNo compatible versions installedmessage rather than aborting the parse.asdfDataDir()— respects$ASDF_DATA_DIR(the data dir override) before falling back to$HOME/.asdf, using thehomeDirseam already added by Volta for cross-platform test isolation.Install,Uninstall,Use,SetDefault,GlobalNpmPrefix) returnErrASDFNotImplemented— same sentinel pattern as the other Phase-1 managers.Tests
19 mocked tests across:
parseASDFVersionparseASDFInstalledDetectbranches$ASDF_DATA_DIR, empty env falls throughName,Version× 4,ListInstalled× 3ErrASDFNotImplementedasdfDataDirenv-wins, home-fallback, empty-home, whitespace-trim, no-shell-on-PATHgo test ./...passes;gofmtandgo vetclean.Out of scope (Phase 1)
Mutation commands — Install / Uninstall / Use / SetDefault / GlobalNpmPrefix — are stubbed with
ErrASDFNotImplementedper the project plan. They will be implemented when the upgrade command lands in Phase 4.Part of the Phase 1 detector rollout (FNM #1, NVM #2, Volta #3, this one #4).