Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,23 @@ func Find(version string) (string, string, error) {
isUserAlias = true
}

resolvedViaAlias := false
if isUserAlias || lower == "latest" || lower == "lts" || strings.HasPrefix(lower, "lts/") {
resolved, err := alias(lower)
if err != nil {
return "", "", err
}
v = resolved
resolvedViaAlias = true
}

// Strip prerelease/build metadata for matching purposes.
// Prereleases will not be supported until the new Node.js schedule is
// implemented with Alpha releases.
v = strings.Split(v, "-")[0]

// After alias resolution the target may already be exact (user alias,
// default/current, or latest/lts). Skip a second index.tab fetch.
if resolvedViaAlias && isExactVersionSpec(v) {
// Exact x.y.z is already concrete (typed by the user, or after alias
// resolution). Skip index.tab so air-gapped `nvm install 24.22.1` can
// use a local archive without DNS.
if isExactVersionSpec(v) {
return NormalizeVersion(v), "", nil
}

Expand Down
18 changes: 18 additions & 0 deletions resolver/resolver_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package resolver

import "testing"

func TestFindExactVersionSkipsCatalog(t *testing.T) {
for _, spec := range []string{"24.22.1", "v24.22.1", "24.22.1-rc.1"} {
got, npm, err := Find(spec)
if err != nil {
t.Fatalf("Find(%q) error = %v", spec, err)
}
if got != "24.22.1" {
t.Fatalf("Find(%q) = %q, want 24.22.1", spec, got)
}
if npm != "" {
t.Fatalf("Find(%q) npm = %q, want empty (no catalog)", spec, npm)
}
}
}
Loading