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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
part of #48 — `packages.go` was the last `RunE` file in the tree
still using `context.Background()`. The unused `"context"`
import is dropped. Closes #49.
- `internal/detector/system_node.go`: the asdf branch of
`managerManagedRoots` was reading `$ASDF_DIR` to discover the
manager's data dir, while `asdfDataDir()` (the function the
detector's actual `Install`/`ListInstalled` paths shell out
against) reads `$ASDF_DATA_DIR` — and `docs/managers.md`
documented `$ASDF_DIR` in the supported-manager table. The three
were inconsistent: a user with `ASDF_DIR=/path/to/asdf-source`
(the source checkout from git-clone) would have `nodeup` classify
the `node` binary under that source dir as `manager`-managed even
though the manager's actual install location was elsewhere
(typically `~/.asdf`), and a user with the canonical `ASDF_DATA_DIR`
override would have it silently ignored by the path classifier.
Unified all three on `$ASDF_DATA_DIR`, matching the variable
`asdfDataDir()` already used and the official asdf docs.
Updated `system_node_test.go`'s "asdf env wins" case to drive
the new variable. Closes #50.

## [0.0.0] - 2024-07-01

Expand Down
2 changes: 1 addition & 1 deletion docs/managers.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ priority order — earlier managers win when multiple are installed.
| [fnm](https://github.com/Schniz/fnm) | macOS, Linux, Windows | `fnm` on PATH, `FNM_DIR`, `~/Library/Application Support/fnm` (macOS) / `~/.local/share/fnm` (Linux) / `%AppData%\fnm` (Windows) |
| [nvm](https://github.com/nvm-sh/nvm) | macOS, Linux | `NVM_DIR`, `~/.nvm/nvm.sh` |
| [Volta](https://volta.sh) | macOS, Linux, Windows | `volta` on PATH, `VOLTA_HOME`, `~/.volta` |
| [asdf](https://asdf-vm.com) | macOS, Linux | `asdf` on PATH, `ASDF_DIR`, `~/.asdf`, `nodejs` plugin |
| [asdf](https://asdf-vm.com) | macOS, Linux | `asdf` on PATH, `ASDF_DATA_DIR`, `~/.asdf`, `nodejs` plugin |
| [mise](https://mise.jdx.dev) | macOS, Linux | `mise` on PATH, `node` plugin |
| [n](https://github.com/tj/n) | macOS, Linux | `n` on PATH, `N_PREFIX` |
| [nodenv](https://github.com/nodenv/nodenv) | macOS, Linux | `nodenv` on PATH, `~/.nodenv/shims` |
Expand Down
2 changes: 1 addition & 1 deletion internal/detector/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Detection priority (highest first):
// 1. --manager CLI flag (caller-supplied)
// 2. ~/.nodeup/config.yaml setting
// 3. environment variables (NVM_DIR, FNM_DIR, VOLTA_HOME, ASDF_DIR, ...)
// 3. environment variables (NVM_DIR, FNM_DIR, VOLTA_HOME, ASDF_DATA_DIR, ...)
// 4. binary lookup on PATH
// 5. well-known data directories
//
Expand Down
12 changes: 11 additions & 1 deletion internal/detector/system_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,17 @@ func managerManagedRoots(m Manager) (roots []string, ok bool) {
}
return []string{}, true
case "asdf":
if d := strings.TrimSpace(getenv("ASDF_DIR")); d != "" {
// $ASDF_DATA_DIR is the canonical override (matches
// asdfDataDir()'s view of the same variable, which is what
// the detector's Install/ListInstalled actually shell out
// against). $ASDF_DIR is a separate variable pointing at
// the asdf source checkout — not a data dir, not where
// versions live — and using it here would let the
// classifier claim a node binary under
// `/path/to/asdf-source/shims/node` is manager-managed when
// the manager's actual data dir is somewhere else entirely.
// See issue #50.
if d := strings.TrimSpace(getenv("ASDF_DATA_DIR")); d != "" {
return []string{d}, true
}
if h, err := userHomeDir(); err == nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/detector/system_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func TestManagerManagedRoots(t *testing.T) {
// "fall back to home" assertions noisy. t.Setenv saves and
// restores each one to its pre-test value.
for _, v := range []string{
"FNM_DIR", "NVM_DIR", "VOLTA_HOME", "ASDF_DIR",
"FNM_DIR", "NVM_DIR", "VOLTA_HOME", "ASDF_DIR", "ASDF_DATA_DIR",
"MISE_DATA_DIR", "N_PREFIX", "NODENV_ROOT",
"XDG_DATA_HOME",
} {
Expand Down Expand Up @@ -366,10 +366,10 @@ func TestManagerManagedRoots(t *testing.T) {
},
{
name: "asdf env wins",
mgr: "asdf", envKey: "ASDF_DIR", envVal: "/opt/asdf",
mgr: "asdf", envKey: "ASDF_DATA_DIR", envVal: "/opt/asdf",
wantRoots: []string{"/opt/asdf"},
wantOK: true,
description: "ASDF_DIR override",
description: "ASDF_DATA_DIR override (canonical asdf data-dir env)",
},
{
name: "mise env wins",
Expand Down
Loading