Guarding npm version printing with NVM_SILENT flag check; when sourcing nvm.sh, a considerable amount of time is spent running npm --version only for that output to be black-holed to /dev/null

Alan Quach 2015-07-09 09:56:26 +10:00
parent f2d31b0458
commit 9419794b19
1 changed files with 3 additions and 1 deletions

4
nvm.sh
View File

@ -61,7 +61,7 @@ nvm_has_system_iojs() {
}
nvm_print_npm_version() {
if nvm_has "npm"; then
if [ "$NVM_SILENT" != "true" ] && nvm_has "npm"; then
echo " (npm v$(npm --version 2>/dev/null))"
fi
}
@ -1882,7 +1882,9 @@ if nvm_supports_source_options && [ "_$1" = "_--install" ]; then
nvm install >/dev/null
fi
elif [ -n "$VERSION" ]; then
NVM_SILENT="true"
nvm use "$VERSION" >/dev/null
unset NVM_SILENT
elif nvm_rc_version >/dev/null 2>&1; then
nvm use >/dev/null
fi