Skip to content
Myr

Add nvm_is_valid_version

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jordan Harband · committed by Jordan Harband · parent 8a87133 · Browse files · 2 files+29 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+29 added−0 removed

  • tests:+13 added−0 removed
  • other:+16 added−0 removed

2 files+29 added−0 removed

added:test/fast/Unit tests/nvm_is_valid_version+13 added
1#!/bin/sh23die () { echo $@ ; exit 1; }45. ../../../nvm.sh67nvm_is_valid_version 0.1.2 || die "nvm_is_valid_version 0.1.2 did not return 0"8nvm_is_valid_version foo && die "nvm_is_valid_version foo did not return 1"9nvm_is_valid_version iojs-1 || die "nvm_is_valid_version iojs-1 did not return 0"10nvm_is_valid_version iojs || die "nvm_is_valid_version iojs did not return 0"11nvm_is_valid_version node || die "nvm_is_valid_version node did not return 0"12nvm_is_valid_version stable || die "nvm_is_valid_version stable did not return 0"13nvm_is_valid_version unstable || die "nvm_is_valid_version unstable did not return 0"
modified:nvm.sh+16 added
261 unmodified lines
262 echo "$VERSIONS"263 fi264}265266nvm_is_valid_version() {267 if nvm_validate_implicit_alias "$1" 2> /dev/null; then268 return 0269 fi270 case "$1" in271 "$(nvm_iojs_prefix)" | "$(nvm_node_prefix)")272 return 0273 ;;274 *)275 local VERSION276 VERSION="$(nvm_strip_iojs_prefix "$1")"277 nvm_version_greater "$VERSION"278 ;;279 esac280}281282nvm_normalize_version() {283 echo "$1" | command sed -e 's/^v//' | command awk -F. '{ printf("%d%06d%06d\n", $1,$2,$3); }'284}285
1275 unmodified lines