|
84 | 84 | phpvm_echo >&2 'Failed to install Node.js dependencies. Please report this!'
|
85 | 85 | exit 1
|
86 | 86 | }
|
87 |
| - |
88 |
| - # Make the phpvm binary executable |
89 |
| - phpvm_echo "=> Making phpvm binary executable" |
90 |
| - chmod +x "$INSTALL_DIR/bin/phpvm" || { |
91 |
| - phpvm_echo >&2 'Failed to set execute permissions on phpvm binary. Please report this!' |
92 |
| - exit 1 |
93 |
| - } |
94 |
| - } |
95 |
| - |
96 |
| - phpvm_detect_profile() { |
97 |
| - if [ "${PROFILE-}" = '/dev/null' ]; then |
98 |
| - return |
99 |
| - fi |
100 |
| - |
101 |
| - if [ -n "${PROFILE}" ] && [ -f "${PROFILE}" ]; then |
102 |
| - phpvm_echo "${PROFILE}" |
103 |
| - return |
104 |
| - fi |
105 |
| - |
106 |
| - local SHELL_TYPE |
107 |
| - SHELL_TYPE="$(basename "$SHELL")" |
108 |
| - |
109 |
| - if [ "$SHELL_TYPE" = "bash" ]; then |
110 |
| - if [ -f "$HOME/.bashrc" ]; then |
111 |
| - phpvm_echo "$HOME/.bashrc" |
112 |
| - elif [ -f "$HOME/.bash_profile" ]; then |
113 |
| - phpvm_echo "$HOME/.bash_profile" |
114 |
| - fi |
115 |
| - elif [ "$SHELL_TYPE" = "zsh" ]; then |
116 |
| - if [ -f "$HOME/.zshrc" ]; then |
117 |
| - phpvm_echo "$HOME/.zshrc" |
118 |
| - elif [ -f "$HOME/.zprofile" ]; then |
119 |
| - phpvm_echo "$HOME/.zprofile" |
120 |
| - fi |
121 |
| - fi |
122 | 87 | }
|
123 | 88 |
|
124 | 89 | inject_phpvm_config() {
|
|
128 | 93 | PROFILE_INSTALL_DIR="$(phpvm_install_dir | command sed "s:^$HOME:\$HOME:")"
|
129 | 94 |
|
130 | 95 | PHPVM_CONFIG_STR="
|
131 |
| -
|
132 |
| -# Set up PHPVM environment |
133 |
| -export PHPVM_DIR=\"${PROFILE_INSTALL_DIR}\" |
134 |
| -
|
135 |
| -# Only source phpvm if it's needed (for auto-switching versions) |
136 |
| -phpvm_auto_switch_on_cd() { |
137 |
| - local PHPVMRC_FILE=\"\$(phpvm_find_phpvmrc)\" |
138 |
| - if [ -n \"\$PHPVMRC_FILE\" ]; then |
139 |
| - local PHP_VERSION=\$(cat \"\$PHPVMRC_FILE\") |
140 |
| - if [ -n \"\$PHP_VERSION\" ]; then |
141 |
| - phpvm use \$PHP_VERSION |
142 |
| - else |
143 |
| - echo 'No PHP version specified in .phpvmrc' |
144 |
| - fi |
145 |
| - fi |
146 |
| -} |
147 |
| -
|
148 |
| -# Update 'cd' command to automatically switch versions based on .phpvmrc |
149 |
| -cd() { |
150 |
| - builtin cd \"\$@\" || return |
151 |
| - phpvm_auto_switch_on_cd |
152 |
| -} |
153 |
| -
|
154 | 96 | # Load PHPVM if necessary (this will allow phpvm to be invoked manually)
|
155 | 97 | if [ -s \"\$PHPVM_DIR/index.js\" ]; then
|
156 | 98 | export PATH=\"\$PHPVM_DIR/bin:\$PATH\"
|
157 | 99 | fi
|
158 | 100 | "
|
159 | 101 |
|
160 | 102 | if [ -n "$PHPVM_PROFILE" ]; then
|
161 |
| - if ! command grep -qc 'phpvm_auto_switch_on_cd' "$PHPVM_PROFILE"; then |
| 103 | + if ! command grep -qc '/phpvm/index.js' "$PHPVM_PROFILE"; then |
162 | 104 | phpvm_echo "=> Injecting phpvm config into $PHPVM_PROFILE"
|
163 | 105 | echo -e "$PHPVM_CONFIG_STR" >>"$PHPVM_PROFILE"
|
164 | 106 | else
|
|
0 commit comments