Merge branch 'master' into add-current-command
commit
f9d5a85f05
|
@ -25,6 +25,8 @@ if [ ! -z "$1" ]; then
|
||||||
else
|
else
|
||||||
if [ -f "$HOME/.bash_profile" ]; then
|
if [ -f "$HOME/.bash_profile" ]; then
|
||||||
PROFILE="$HOME/.bash_profile"
|
PROFILE="$HOME/.bash_profile"
|
||||||
|
elif [ -f "$HOME/.zshrc" ]; then
|
||||||
|
PROFILE="$HOME/.zshrc"
|
||||||
elif [ -f "$HOME/.profile" ]; then
|
elif [ -f "$HOME/.profile" ]; then
|
||||||
PROFILE="$HOME/.profile"
|
PROFILE="$HOME/.profile"
|
||||||
fi
|
fi
|
||||||
|
|
30
nvm.sh
30
nvm.sh
|
@ -7,9 +7,14 @@
|
||||||
# Implemented by Tim Caswell <tim@creationix.com>
|
# Implemented by Tim Caswell <tim@creationix.com>
|
||||||
# with much bash help from Matthew Ranney
|
# with much bash help from Matthew Ranney
|
||||||
|
|
||||||
|
has() {
|
||||||
|
type "$1" > /dev/null 2>&1
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
# Make zsh glob matching behave same as bash
|
# Make zsh glob matching behave same as bash
|
||||||
# This fixes the "zsh: no matches found" errors
|
# This fixes the "zsh: no matches found" errors
|
||||||
if [ ! -z "$(which unsetopt 2>/dev/null)" ]; then
|
if has "unsetopt"; then
|
||||||
unsetopt nomatch 2>/dev/null
|
unsetopt nomatch 2>/dev/null
|
||||||
NVM_CD_FLAGS="-q"
|
NVM_CD_FLAGS="-q"
|
||||||
fi
|
fi
|
||||||
|
@ -20,7 +25,7 @@ if [ ! -d "$NVM_DIR" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nvm_set_nullglob() {
|
nvm_set_nullglob() {
|
||||||
if type setopt > /dev/null 2>&1; then
|
if has "setopt"; then
|
||||||
# Zsh
|
# Zsh
|
||||||
setopt NULL_GLOB
|
setopt NULL_GLOB
|
||||||
else
|
else
|
||||||
|
@ -202,11 +207,11 @@ nvm() {
|
||||||
local shasum='shasum'
|
local shasum='shasum'
|
||||||
local nobinary
|
local nobinary
|
||||||
|
|
||||||
if [ ! `\which curl` ]; then
|
if ! has "curl"; then
|
||||||
echo 'NVM Needs curl to proceed.' >&2;
|
echo 'NVM Needs curl to proceed.' >&2;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "`which shasum`" ]; then
|
if ! has "shasum"; then
|
||||||
shasum='sha1sum'
|
shasum='sha1sum'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -262,8 +267,8 @@ nvm() {
|
||||||
curl -L -C - --progress-bar $url -o "$tmptarball" && \
|
curl -L -C - --progress-bar $url -o "$tmptarball" && \
|
||||||
nvm_checksum `${shasum} "$tmptarball" | awk '{print $1}'` $sum && \
|
nvm_checksum `${shasum} "$tmptarball" | awk '{print $1}'` $sum && \
|
||||||
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||||
mv "$tmpdir" "$NVM_DIR/$VERSION" && \
|
rm -f "$tmptarball" && \
|
||||||
rm -f "$tmptarball"
|
mv "$tmpdir" "$NVM_DIR/$VERSION"
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
nvm use $VERSION
|
nvm use $VERSION
|
||||||
|
@ -306,7 +311,7 @@ nvm() {
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
nvm use $VERSION
|
nvm use $VERSION
|
||||||
if ! which npm ; then
|
if ! has "npm" ; then
|
||||||
echo "Installing npm..."
|
echo "Installing npm..."
|
||||||
if [[ "`expr match $VERSION '\(^v0\.1\.\)'`" != '' ]]; then
|
if [[ "`expr match $VERSION '\(^v0\.1\.\)'`" != '' ]]; then
|
||||||
echo "npm requires node v0.2.3 or higher"
|
echo "npm requires node v0.2.3 or higher"
|
||||||
|
@ -389,7 +394,7 @@ nvm() {
|
||||||
if [ -z $VERSION ]; then
|
if [ -z $VERSION ]; then
|
||||||
VERSION=`nvm_version $2`
|
VERSION=`nvm_version $2`
|
||||||
fi
|
fi
|
||||||
if [ ! -d $NVM_DIR/$VERSION ]; then
|
if [ ! -d "$NVM_DIR/$VERSION" ]; then
|
||||||
echo "$VERSION version is not installed yet"
|
echo "$VERSION version is not installed yet"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -482,10 +487,11 @@ nvm() {
|
||||||
nvm help
|
nvm help
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
VERSION=`nvm_version $2`
|
local VERSION=`nvm_version $2`
|
||||||
ROOT=`nvm use $VERSION && npm -g root`
|
local ROOT=`nvm use $VERSION && npm -g root`
|
||||||
INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f 8 | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "`
|
local ROOTDEPTH=$((`echo $ROOT | sed 's/[^\/]//g'|wc -m` -1))
|
||||||
npm install -g $INSTALLS
|
local INSTALLS=( `nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f $(($ROOTDEPTH + 2)) | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "` )
|
||||||
|
npm install -g ${INSTALLS[@]}
|
||||||
;;
|
;;
|
||||||
"clear-cache" )
|
"clear-cache" )
|
||||||
rm -f $NVM_DIR/v* 2>/dev/null
|
rm -f $NVM_DIR/v* 2>/dev/null
|
||||||
|
|
Loading…
Reference in New Issue