Skip to content
This repository

Removed the prepended number from remote_version and checksum #212

Closed
wants to merge 1 commit into from

2 participants

Wong Liang Zan Jordan Harband
Wong Liang Zan

nvm_remote_version returns 5:v0.10.2. When that is substituted to form the node filename node-5:v0.10.2-darwin-x86_64.tar.gz. I used pattern substitution to remove the prepended number and colon.

The same problem appears for comparing checksums. The first checksum argument would return foo while the second argument returns 1:foo. I used the same technique to remove the prepended number and colon.

Please feel free to improve the shell code.

Jordan Harband
Collaborator
ljharb commented

nvm_remote_version no longer seems to have anything prepended for me. Please reopen if this is still the case.

Jordan Harband ljharb closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 29, 2013
Wong Liang Zan liangzan corrected the incorrect strings for version and sum e094fdd
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 2 deletions. Show diff stats Hide diff stats

  1. +5 2 nvm.sh
7 nvm.sh
@@ -45,7 +45,9 @@ nvm_remote_version()
45 45 {
46 46 local PATTERN=$1
47 47 VERSION=`nvm_ls_remote $PATTERN | tail -n1`
48   - echo "$VERSION"
  48 + EV_VERSION="$VERSION"
  49 + SPLIT_VERSION=(${EV_VERSION//*:/})
  50 + echo ${SPLIT_VERSION}
49 51
50 52 if [ "$VERSION" = 'N/A' ]; then
51 53 return
@@ -239,11 +241,12 @@ nvm()
239 241 t="$VERSION-$os-$arch"
240 242 url="http://nodejs.org/dist/$VERSION/node-${t}.tar.gz"
241 243 sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt | grep node-${t}.tar.gz | awk '{print $1}'`
  244 + split_sum=(${sum//*:/})
242 245 if (
243 246 mkdir -p "$NVM_DIR/bin/node-${t}" && \
244 247 cd "$NVM_DIR/bin" && \
245 248 curl -C - --progress-bar $url -o "node-${t}.tar.gz" && \
246   - nvm_checksum `${shasum} node-${t}.tar.gz | awk '{print $1}'` $sum && \
  249 + nvm_checksum `${shasum} node-${t}.tar.gz | awk '{print $1}'` $split_sum && \
247 250 tar -xzf "node-${t}.tar.gz" -C "node-${t}" --strip-components 1 && \
248 251 mv "node-${t}" "../$VERSION" && \
249 252 rm -f "node-${t}.tar.gz"

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.