File tree Expand file tree Collapse file tree 3 files changed +73
-2
lines changed Expand file tree Collapse file tree 3 files changed +73
-2
lines changed Original file line number Diff line number Diff line change @@ -1102,7 +1102,7 @@ nvm() {
1102
1102
echo " 0.21.0"
1103
1103
;;
1104
1104
" unload" )
1105
- unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater nvm_version_greater_than_or_equal_to > /dev/null 2>&1
1105
+ unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater nvm_version_greater_than_or_equal_to nvm_supports_source_options > /dev/null 2>&1
1106
1106
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
1107
1107
;;
1108
1108
* )
@@ -1111,7 +1111,18 @@ nvm() {
1111
1111
esac
1112
1112
}
1113
1113
1114
- if nvm ls default > /dev/null; then
1114
+ nvm_supports_source_options () {
1115
+ [ " _$( echo ' echo $1' | . /dev/stdin yes) " = " _yes" ]
1116
+ }
1117
+
1118
+ if nvm_supports_source_options && [ " _$1 " = " _--install" ]; then
1119
+ VERSION=" $( nvm_alias default 2> /dev/null) "
1120
+ if [ -n " $VERSION " ]; then
1121
+ nvm install " $VERSION " > /dev/null
1122
+ elif nvm_rc_version > /dev/null 2>&1 ; then
1123
+ nvm install > /dev/null
1124
+ fi
1125
+ elif nvm ls default > /dev/null; then
1115
1126
nvm use default > /dev/null
1116
1127
elif nvm_rc_version > /dev/null 2>&1 ; then
1117
1128
nvm use > /dev/null
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ die () { echo $@ ; exit 1; }
4
+ supports_source_options () {
5
+ [ " _$( echo ' echo $1' | . /dev/stdin yes) " = " _yes" ]
6
+ }
7
+
8
+ if ! supports_source_options; then
9
+ echo ' this shell does not support passing options on sourcing'
10
+ exit 0;
11
+ fi
12
+
13
+ echo ' 0.10.2' > ../../.nvmrc || die ' creation of .nvmrc failed'
14
+
15
+ . ../../nvm.sh --install
16
+ EXIT_CODE=" $( echo $? ) "
17
+
18
+ echo ' sourcing complete.'
19
+
20
+ nvm_version 0.10.2 > /dev/null 2>&1 || die " v0.10.2 not installed: $( nvm ls) "
21
+
22
+ [ " _$( nvm_rc_version | \g rep -o -e ' with version .*$' ) " = " _with version <0.10.2>" ] || die " nvm_rc_version $( nvm_rc_version) "
23
+
24
+ [ " _$EXIT_CODE " = " _0" ] || die " sourcing returned nonzero exit code: $EXIT_CODE "
25
+
26
+ NVM_LS_CURRENT=" $( nvm ls current | \g rep -o v0.10.2) "
27
+ [ " _$NVM_LS_CURRENT " = ' _v0.10.2' ] || die " 'nvm ls current' did not return '-> v0.10.2', got '$NVM_LS_CURRENT ' ` nvm ls` "
28
+
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ die () { echo $@ ; exit 1; }
4
+ supports_source_options () {
5
+ [ " _$( echo ' echo $1' | . /dev/stdin yes) " = " _yes" ]
6
+ }
7
+
8
+ if ! supports_source_options; then
9
+ echo ' this shell does not support passing options on sourcing'
10
+ exit 0;
11
+ fi
12
+
13
+ echo ' 0.10.2' > ../../alias/default || die ' creation of default alias failed'
14
+
15
+ echo ' sourcing nvm with --install...'
16
+
17
+ . ../../nvm.sh --install
18
+ EXIT_CODE=" $( echo $? ) "
19
+
20
+ echo ' sourcing complete.'
21
+
22
+ nvm_version 0.10.2 > /dev/null 2>&1 || die " v0.10.2 not installed: $( nvm ls) "
23
+
24
+ [ " _$EXIT_CODE " = " _0" ] || die " sourcing returned nonzero exit code: $EXIT_CODE "
25
+
26
+ NVM_LS_CURRENT=" $( nvm ls current | \g rep -o v0.10.2) "
27
+ [ " _$NVM_LS_CURRENT " = ' _v0.10.2' ] || die " 'nvm ls current' did not return '-> v0.10.2', got '$NVM_LS_CURRENT '"
28
+
29
+ NVM_ALIAS_DEFAULT=" $( nvm alias default) "
30
+ [ " _$NVM_ALIAS_DEFAULT " = " _default -> 0.10.2 (-> v0.10.2)" ] \
31
+ || die " 'nvm alias default did not return 'default -> 0.10.2 (-> v0.10.2)', got '$NVM_ALIAS_DEFAULT '"
32
+
You can’t perform that action at this time.
0 commit comments