Merge pull request #256 from cliffano/master
Add sh directive and replace bash function with sh function.master
commit
8b9c0b933c
27
nvm.sh
27
nvm.sh
|
@ -1,3 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
# Node Version Manager
|
# Node Version Manager
|
||||||
# Implemented as a bash function
|
# Implemented as a bash function
|
||||||
# To use source this file from your bash profile
|
# To use source this file from your bash profile
|
||||||
|
@ -16,7 +18,7 @@ if [ ! -z "$(which unsetopt 2>/dev/null)" ]; then
|
||||||
unsetopt nomatch 2>/dev/null
|
unsetopt nomatch 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function nvm_set_nullglob {
|
nvm_set_nullglob() {
|
||||||
if type setopt > /dev/null 2>&1; then
|
if type setopt > /dev/null 2>&1; then
|
||||||
# Zsh
|
# Zsh
|
||||||
setopt NULL_GLOB
|
setopt NULL_GLOB
|
||||||
|
@ -27,7 +29,7 @@ function nvm_set_nullglob {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Obtain nvm version from rc file
|
# Obtain nvm version from rc file
|
||||||
function rc_nvm_version {
|
rc_nvm_version() {
|
||||||
if [ -e .nvmrc ]; then
|
if [ -e .nvmrc ]; then
|
||||||
RC_VERSION=`cat .nvmrc | head -n 1`
|
RC_VERSION=`cat .nvmrc | head -n 1`
|
||||||
echo "Found .nvmrc files with version <$RC_VERSION>"
|
echo "Found .nvmrc files with version <$RC_VERSION>"
|
||||||
|
@ -35,8 +37,7 @@ function rc_nvm_version {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Expand a version using the version cache
|
# Expand a version using the version cache
|
||||||
nvm_version()
|
nvm_version() {
|
||||||
{
|
|
||||||
local PATTERN=$1
|
local PATTERN=$1
|
||||||
# The default version is the current one
|
# The default version is the current one
|
||||||
if [ ! "$PATTERN" ]; then
|
if [ ! "$PATTERN" ]; then
|
||||||
|
@ -51,8 +52,7 @@ nvm_version()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_remote_version()
|
nvm_remote_version() {
|
||||||
{
|
|
||||||
local PATTERN=$1
|
local PATTERN=$1
|
||||||
VERSION=`nvm_ls_remote $PATTERN | tail -n1`
|
VERSION=`nvm_ls_remote $PATTERN | tail -n1`
|
||||||
echo "$VERSION"
|
echo "$VERSION"
|
||||||
|
@ -62,8 +62,7 @@ nvm_remote_version()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_ls()
|
nvm_ls() {
|
||||||
{
|
|
||||||
local PATTERN=$1
|
local PATTERN=$1
|
||||||
local VERSIONS=''
|
local VERSIONS=''
|
||||||
if [ "$PATTERN" = 'current' ]; then
|
if [ "$PATTERN" = 'current' ]; then
|
||||||
|
@ -90,8 +89,7 @@ nvm_ls()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_ls_remote()
|
nvm_ls_remote() {
|
||||||
{
|
|
||||||
local PATTERN=$1
|
local PATTERN=$1
|
||||||
local VERSIONS
|
local VERSIONS
|
||||||
if [ "$PATTERN" ]; then
|
if [ "$PATTERN" ]; then
|
||||||
|
@ -113,8 +111,7 @@ nvm_ls_remote()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_checksum()
|
nvm_checksum() {
|
||||||
{
|
|
||||||
if [ "$1" = "$2" ]; then
|
if [ "$1" = "$2" ]; then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
|
@ -124,8 +121,7 @@ nvm_checksum()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
print_versions()
|
print_versions() {
|
||||||
{
|
|
||||||
local OUTPUT=''
|
local OUTPUT=''
|
||||||
local PADDED_VERSION=''
|
local PADDED_VERSION=''
|
||||||
for VERSION in $1; do
|
for VERSION in $1; do
|
||||||
|
@ -138,8 +134,7 @@ print_versions()
|
||||||
echo -e "$OUTPUT"
|
echo -e "$OUTPUT"
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm()
|
nvm() {
|
||||||
{
|
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
nvm help
|
nvm help
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue