Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:
  nvm_version_greater_than_or_equal_to "$NODE_VERSION" v0.8.6
}

nvm_has_solaris_binary() {
  local VERSION=$1
  if nvm_is_iojs_version "$VERSION"; then
    iojs_version_has_solaris_binary "$VERSION"
  else
    node_version_has_solaris_binary "$VERSION"
  fi
}

nvm() {
  if [ $# -lt 1 ]; then
    nvm help
    return
  fi

  local GREP_OPTIONS
  GREP_OPTIONS=''

  # initialize local variables
  local VERSION
  local ADDITIONAL_PARAMETERS
  local ALIAS

  case $1 in
    "help" )
      local NVM_IOJS_PREFIX
      NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
      local NVM_NODE_PREFIX
      NVM_NODE_PREFIX="$(nvm_node_prefix)"
      echo
      echo "Node Version Manager"
      echo
      echo 'Note: <version> refers to any version-like string nvm understands. This includes:'
      echo '  - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)'
      echo "  - default (built-in) aliases: $NVM_NODE_PREFIX, stable, unstable, $NVM_IOJS_PREFIX, system"
      echo '  - custom aliases you define with `nvm alias foo`'
      echo
      echo 'Usage:'
      echo '  nvm help                                  Show this message'
      echo '  nvm --version                             Print out the latest released version of nvm'
      echo '  nvm install [-s] <version>                Download and install a <version>, [-s] from source. Uses .nvmrc if available'
      echo '    --reinstall-packages-from=<version>     When installing, reinstall packages installed in <node|iojs|node version number>'
      echo '  nvm uninstall <version>                   Uninstall a version'
      echo '  nvm use [--silent] <version>              Modify PATH to use <version>. Uses .nvmrc if available'
      echo '  nvm exec [--silent] <version> [<command>] Run <command> on <version>. Uses .nvmrc if available'
      echo '  nvm run [--silent] <version> [<args>]     Run `node` on <version> with <args> as arguments. Uses .nvmrc if available'
      echo '  nvm current                               Display currently activated version'
      echo '  nvm ls                                    List installed versions'

Review comment (refactor):
Actually, updated this PR with a commit that factors out `try_version`. If that's not OK, i'll just remove this commit when squashing before merging.


Code after:
  # io.js started shipping Solaris binaries with io.js v3.3.1
  nvm_version_greater_than_or_equal_to "$STRIPPED_IOJS_VERSION" v3.3.1
}

# Succeeds if $NODE_VERSION represents a node version that has a
# Solaris binary, fails otherwise.
# Currently, node versions starting from v0.8.6 have a Solaris binary
# avaliable.
node_version_has_solaris_binary() {
  local NODE_VERSION=$1
  # Error out if $NODE_VERSION is actually an io.js version
  local STRIPPED_IOJS_VERSION="$(nvm_strip_iojs_prefix $NODE_VERSION)"
  if [ "_$STRIPPED_IOJS_VERSION" != "_$NODE_VERSION" ]; then
    return 1
  fi

  # node (unmerged) started shipping Solaris binaries with v0.8.6 and
  # node versions v1.0.0 or greater are not considered valid "unmerged" node
  # versions.
  nvm_version_greater_than_or_equal_to "$NODE_VERSION" v0.8.6 &&
  ! nvm_version_greater_than_or_equal_to "$NODE_VERSION" v1.0.0
}

# Succeeds if $VERSION represents a version (node, io.js or merged) that has a
# Solaris binary, fails otherwise.
nvm_has_solaris_binary() {
  local VERSION=$1
  if nvm_is_merged_node_version "$VERSION"; then
    return 0 # All merged node versions have a Solaris binary
  elif nvm_is_iojs_version "$VERSION"; then
    iojs_version_has_solaris_binary "$VERSION"
  else
    node_version_has_solaris_binary "$VERSION"
  fi
}

nvm() {
  if [ $# -lt 1 ]; then
    nvm help
    return
  fi

  local GREP_OPTIONS
  GREP_OPTIONS=''

  # initialize local variables
  local VERSION
  local ADDITIONAL_PARAMETERS
  local ALIAS

  case $1 in