[Refactor] Use "case" instead of multi "if"
parent
47c60dfc1d
commit
84575cf353
23
nvm.sh
23
nvm.sh
|
@ -1778,15 +1778,20 @@ nvm_get_make_jobs() {
|
||||||
local NVM_OS
|
local NVM_OS
|
||||||
NVM_OS="$(nvm_get_os)"
|
NVM_OS="$(nvm_get_os)"
|
||||||
local NVM_CPU_CORES
|
local NVM_CPU_CORES
|
||||||
if [ "_$NVM_OS" = "_linux" ]; then
|
case "_$NVM_OS" in
|
||||||
NVM_CPU_CORES="$(nvm_grep -c -E '^processor.+: [0-9]+' /proc/cpuinfo)"
|
"_linux")
|
||||||
elif [ "_$NVM_OS" = "_freebsd" ] || [ "_$NVM_OS" = "_darwin" ]; then
|
NVM_CPU_CORES="$(nvm_grep -c -E '^processor.+: [0-9]+' /proc/cpuinfo)"
|
||||||
NVM_CPU_CORES="$(sysctl -n hw.ncpu)"
|
;;
|
||||||
elif [ "_$NVM_OS" = "_sunos" ]; then
|
"_freebsd" | "_darwin")
|
||||||
NVM_CPU_CORES="$(psrinfo | wc -l)"
|
NVM_CPU_CORES="$(sysctl -n hw.ncpu)"
|
||||||
elif [ "_$NVM_OS" = "_aix" ]; then
|
;;
|
||||||
NVM_CPU_CORES="$(pmcycles -m | wc -l)"
|
"_sunos")
|
||||||
fi
|
NVM_CPU_CORES="$(psrinfo | wc -l)"
|
||||||
|
;;
|
||||||
|
"_aix")
|
||||||
|
NVM_CPU_CORES="$(pmcycles -m | wc -l)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
if ! nvm_is_natural_num "$NVM_CPU_CORES" ; then
|
if ! nvm_is_natural_num "$NVM_CPU_CORES" ; then
|
||||||
nvm_err 'Can not determine how many core(s) are available, running in single-threaded mode.'
|
nvm_err 'Can not determine how many core(s) are available, running in single-threaded mode.'
|
||||||
nvm_err 'Please report an issue on GitHub to help us make nvm run faster on your computer!'
|
nvm_err 'Please report an issue on GitHub to help us make nvm run faster on your computer!'
|
||||||
|
|
Loading…
Reference in New Issue