mirror of
https://github.com/ivuorinen/nvm-auto-use.fish.git
synced 2026-01-26 11:14:03 +00:00
- Major refactor of core Fish functions for modularity, caching, and error handling - Improved `.editorconfig` and Makefile for stricter formatting and linting standards - Expanded linting support: added EditorConfig checks, auto-install for missing tools, and Makefile targets - Enhanced CI workflow with clearer permissions and job steps in GitHub Actions - Updated documentation in `README.md` and `CLAUDE.md` to reflect new features, advanced developer tools, and contribution guidelines - Improved Node.js version manager detection, switching, and installation logic - Added/updated utility functions for configuration, silent mode, notifications, and version extraction - Various bug fixes, code quality improvements, and expanded test coverage
72 lines
1.9 KiB
Fish
72 lines
1.9 KiB
Fish
function nvm_compat_detect -d "Detect available Node.js version managers"
|
|
set -l managers
|
|
|
|
if command -q nvm
|
|
set managers $managers nvm
|
|
end
|
|
|
|
if command -q fnm
|
|
set managers $managers fnm
|
|
end
|
|
|
|
if command -q volta
|
|
set managers $managers volta
|
|
end
|
|
|
|
if command -q asdf; and test -f ~/.tool-versions
|
|
if grep -q nodejs ~/.tool-versions 2>/dev/null
|
|
set managers $managers asdf
|
|
end
|
|
end
|
|
|
|
if test (count $managers) -eq 0
|
|
echo "No supported Node.js version managers found"
|
|
return 1
|
|
end
|
|
|
|
echo "Available managers:" (string join ", " $managers)
|
|
echo $managers
|
|
end
|
|
|
|
function nvm_compat_use -a manager version -d "Use specified version with detected manager"
|
|
if test -z "$manager" -o -z "$version"
|
|
echo "Usage: nvm_compat_use <manager> <version>"
|
|
return 1
|
|
end
|
|
|
|
switch $manager
|
|
case nvm
|
|
nvm use $version; or return $status
|
|
case fnm
|
|
fnm use $version; or return $status
|
|
case volta
|
|
volta pin node@$version; or return $status
|
|
case asdf
|
|
asdf local nodejs $version; or return $status
|
|
case '*'
|
|
echo "Unsupported manager: $manager"
|
|
return 1
|
|
end
|
|
end
|
|
|
|
function nvm_compat_install -a manager version -d "Install specified version with detected manager"
|
|
if test -z "$manager" -o -z "$version"
|
|
echo "Usage: nvm_compat_install <manager> <version>"
|
|
return 1
|
|
end
|
|
|
|
switch $manager
|
|
case nvm
|
|
nvm install $version; or return $status
|
|
case fnm
|
|
fnm install $version; or return $status
|
|
case volta
|
|
volta install node@$version; or return $status
|
|
case asdf
|
|
asdf install nodejs $version; or return $status
|
|
case '*'
|
|
echo "Unsupported manager: $manager"
|
|
return 1
|
|
end
|
|
end
|