lib/theme: use `_command_exists()`

pull/1946/head
John D Pell 2022-02-23 16:00:52 -08:00
parent b935ddd309
commit 1a96dd1947
1 changed files with 5 additions and 6 deletions

View File

@ -386,18 +386,17 @@ function hg_prompt_vars {
fi fi
} }
function node_command_version_prompt { function node_command_version_prompt() {
local node_version local node_version
local node_command="$(command -v node)" if _command_exists node; then
if [[ -n "${node_command}" ]]; then node_version="$(node --version 2> /dev/null)"
node_version="$(${node_command} --version 2>/dev/null)"
if [[ -n ${node_version} ]]; then if [[ -n ${node_version} ]]; then
echo -e "${NVM_THEME_PROMPT_PREFIX}${node_version}${NVM_THEME_PROMPT_SUFFIX}" echo -e "${NVM_THEME_PROMPT_PREFIX}${node_version}${NVM_THEME_PROMPT_SUFFIX}"
fi fi
fi fi
} }
function node_version_prompt { function node_version_prompt() {
local node_version="$(nvm_version_prompt)" local node_version="$(nvm_version_prompt)"
if [[ -z "${node_version}" ]]; then if [[ -z "${node_version}" ]]; then
node_version="$(node_command_version_prompt)" node_version="$(node_command_version_prompt)"