Skip to content

Commit 31530db

Browse files
committed
Refactor install.sh to add phpvm_detect_profile function
1 parent a4be795 commit 31530db

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

bin/install.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,34 @@
8686
}
8787
}
8888

89+
phpvm_detect_profile() {
90+
if [ "${PROFILE-}" = '/dev/null' ]; then
91+
return
92+
fi
93+
94+
if [ -n "${PROFILE}" ] && [ -f "${PROFILE}" ]; then
95+
phpvm_echo "${PROFILE}"
96+
return
97+
fi
98+
99+
local SHELL_TYPE
100+
SHELL_TYPE="$(basename "$SHELL")"
101+
102+
if [ "$SHELL_TYPE" = "bash" ]; then
103+
if [ -f "$HOME/.bashrc" ]; then
104+
phpvm_echo "$HOME/.bashrc"
105+
elif [ -f "$HOME/.bash_profile" ]; then
106+
phpvm_echo "$HOME/.bash_profile"
107+
fi
108+
elif [ "$SHELL_TYPE" = "zsh" ]; then
109+
if [ -f "$HOME/.zshrc" ]; then
110+
phpvm_echo "$HOME/.zshrc"
111+
elif [ -f "$HOME/.zprofile" ]; then
112+
phpvm_echo "$HOME/.zprofile"
113+
fi
114+
fi
115+
}
116+
89117
inject_phpvm_config() {
90118
local PHPVM_PROFILE
91119
PHPVM_PROFILE="$(phpvm_detect_profile)"

0 commit comments

Comments
 (0)