Merge pull request #171 from cou929/support_sha1sum_command

support platforms which does not have shasum command
master
Tim Caswell 2012-12-04 17:46:04 -08:00
commit 68f7dc9cb3
1 changed files with 7 additions and 2 deletions

9
nvm.sh
View File

@ -179,11 +179,16 @@ nvm()
local url local url
local sum local sum
local tarball local tarball
local shasum='shasum'
if [ ! `which curl` ]; then if [ ! `which curl` ]; then
echo 'NVM Needs curl to proceed.' >&2; echo 'NVM Needs curl to proceed.' >&2;
fi fi
if [ ! `which shasum > /dev/null 2>&1` ]; then
shasum='sha1sum'
fi
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
nvm help nvm help
return return
@ -217,7 +222,7 @@ nvm()
mkdir -p "$NVM_DIR/bin/node-${t}" && \ mkdir -p "$NVM_DIR/bin/node-${t}" && \
cd "$NVM_DIR/bin" && \ cd "$NVM_DIR/bin" && \
curl -C - --progress-bar $url -o "node-${t}.tar.gz" && \ curl -C - --progress-bar $url -o "node-${t}.tar.gz" && \
nvm_checksum `shasum node-${t}.tar.gz | awk '{print $1}'` $sum && \ nvm_checksum `${shasum} node-${t}.tar.gz | awk '{print $1}'` $sum && \
tar -xzf "node-${t}.tar.gz" -C "node-${t}" --strip-components 1 && \ tar -xzf "node-${t}.tar.gz" -C "node-${t}" --strip-components 1 && \
mv "node-${t}" "../$VERSION" && \ mv "node-${t}" "../$VERSION" && \
rm -f "node-${t}.tar.gz" rm -f "node-${t}.tar.gz"
@ -247,7 +252,7 @@ nvm()
mkdir -p "$NVM_DIR/src" && \ mkdir -p "$NVM_DIR/src" && \
cd "$NVM_DIR/src" && \ cd "$NVM_DIR/src" && \
curl --progress-bar $tarball -o "node-$VERSION.tar.gz" && \ curl --progress-bar $tarball -o "node-$VERSION.tar.gz" && \
if [ "$sum" = "" ]; then : ; else nvm_checksum `shasum node-$VERSION.tar.gz | awk '{print $1}'` $sum; fi && \ if [ "$sum" = "" ]; then : ; else nvm_checksum `${shasum} node-$VERSION.tar.gz | awk '{print $1}'` $sum; fi && \
tar -xzf "node-$VERSION.tar.gz" && \ tar -xzf "node-$VERSION.tar.gz" && \
cd "node-$VERSION" && \ cd "node-$VERSION" && \
./configure --prefix="$NVM_DIR/$VERSION" $ADDITIONAL_PARAMETERS && \ ./configure --prefix="$NVM_DIR/$VERSION" $ADDITIONAL_PARAMETERS && \