Makes nvm a function that gets replaced by the real nvm function.
This means that nvm.sh will only get sourced if it is really
needed, removing a noticable shell startup delay.
After this initialization call, the nvm function will be replaced
by the function that gets loaded from `$INSTALL_DIR/nvm.sh`.
Right after the bootstapping, first run, the command line options
will be passed to the newly sourced nvm function. For the user,
this change is transparent.
Tested with dash, zsh5 and bash4 on my machine. Travis does not
complain.
The following snippet will be added to the shell's start-up file:
``` sh
export NVM_DIR="$HOME/.nvm"
nvm() {
echo Loading nvm for first use in this shell >/dev/stderr
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
nvm "$@"
}
```
makes nvm a function that gets replaced by the real nvm function.
After that, it will get called with the specified arguments. Calls
after this initialization call, will use the original nvm shell
function. By introducing this indirection, shell startup time is
significantly improved.
Line 302/301 `printf "$SOURCE_STR"` is missing a trailing newline char,
while line 281/282 and 285/286 have their own new line char, so I just
remove the manually added newline char, and add it to the end of the
variable "$SOURCE_STR", so no more manually newline char needed there.
On SmartOS setups using 64 bits pkgsrc repositories, `nvm_get_arch`
would not handle pkg_info's output properly.
This would result in nvm not being to install any node binary when
running on SmartOS setups using a 64 bits pkgsrc repository.
This change fixes this problem, and fixes the tests suite on similar
setups.
git-describe was taught `--abbrev=0` in 1.5.0:
https://github.com/git/git/blob/master/Documentation/RelNotes/1.5.0.txt
git-describe was taught `--match` in 1.5.5:
https://github.com/git/git/blob/master/Documentation/RelNotes/1.5.5.txt
I don't see anything else potentially weird in here, so I think it is
safe to proclaim that the minimum git version required to run these
commands is 1.5.5.
Documenting this minimum version required here should help people debug
possible issues and help maintainers of this project understand the
impacts of modifying these commands in the future.
As suggested by @ljharb, this might be a little cleaner. I'm not
entirely sure, but in any case, it is consistent with the upgrade
instructions, so that is nice.
I recently upgraded my copy of nvm and I was disappointed to be dropped
in the .nvm directory at the end of it. I also didn't like having to
copy and paste two separate blocks of code into my terminal, because I
missed the second one the first time around and was left in a slightly
confusing state. So, I decided to make this easier by utilizing
subshells and moving all of the instructions into one code block in this
document. I think this will improve people's experience maintaining this
tool.