Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix installation on msys2/mingw #151

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Install with [Fisher](https://github.com/jorgebucaran/fisher):
fisher install jorgebucaran/nvm.fish
```

> **msys2/mingw** users will need to install unzip if not already installed.

## Quickstart

Install the latest Node release and activate it.
Expand Down
13 changes: 11 additions & 2 deletions functions/nvm.fish
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function nvm --argument-names cmd v --description "Node version manager"
case sunos
case linux
case darwin
case {MSYS_NT,MINGW\*_NT}\*
case {msys_nt,mingw\*_nt}\*
set os win
set ext zip
case \*
Expand All @@ -76,13 +76,22 @@ function nvm --argument-names cmd v --description "Node version manager"

set --local dir "node-$v-$os-$arch"
set --local url $nvm_mirror/$v/$dir.$ext
test "$os" = win && set --local tmp_exe $TMP/(command date +"%s")-$dir.$ext

command mkdir -p $nvm_data/$v

echo -e "Installing Node \x1b[1m$v\x1b[22m $alias"
echo -e "Fetching \x1b[4m$url\x1b[24m\x1b[7m"
if test "$os" = win
if ! command curl --progress-bar --location $url -o $tmp_exe
command rm -rf $nvm_data/$v
echo -e "\033[F\33[2K\x1b[0mnvm: Invalid mirror or host unavailable: \"$url\"" >&2
return 1
end

if ! command curl --progress-bar --location $url \
command unzip -qq -o -d $nvm_data/$v $tmp_exe
rm -rf $tmp_exe
else if ! command curl --progress-bar --location $url \
| command tar --extract --gzip --directory $nvm_data/$v 2>/dev/null
command rm -rf $nvm_data/$v
echo -e "\033[F\33[2K\x1b[0mnvm: Invalid mirror or host unavailable: \"$url\"" >&2
Expand Down