Skip to content

Commit ac2b95a

Browse files
committed
Refactor install.sh to remove unnecessary code, improve installation process, and update global symlink for phpvm
1 parent a4f7308 commit ac2b95a

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

bin/install.sh

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,20 @@ EOL
9797
chmod +x "$INSTALL_DIR/phpvm"
9898

9999
# Copy the launcher script to a directory in the user's PATH
100-
local BIN_DIR="/usr/local/bin"
101-
if [ ! -d "$BIN_DIR" ]; then
102-
BIN_DIR="$HOME/.local/bin"
103-
mkdir -p "$BIN_DIR"
104-
fi
100+
local BIN_DIR="$HOME/.local/bin"
101+
mkdir -p "$BIN_DIR"
105102

106-
sudo cp "$INSTALL_DIR/phpvm" "$BIN_DIR/phpvm" || {
103+
cp "$INSTALL_DIR/phpvm" "$BIN_DIR/phpvm" || {
107104
phpvm_echo >&2 "Failed to copy phpvm to $BIN_DIR. Please ensure you have the necessary permissions."
108105
exit 1
109106
}
110107

111108
# Ensure the script has the correct permissions
112-
sudo chmod +x "$BIN_DIR/phpvm" || {
109+
chmod +x "$BIN_DIR/phpvm" || {
113110
phpvm_echo >&2 "Failed to set execute permissions for phpvm in $BIN_DIR. Please ensure you have the necessary permissions."
114111
exit 1
115112
}
116113

117-
# Additional step to set ownership to the current user to avoid permission issues
118-
sudo chown "$(whoami)" "$BIN_DIR/phpvm" || {
119-
phpvm_echo >&2 "Failed to change ownership of phpvm in $BIN_DIR. Please ensure you have the necessary permissions."
120-
exit 1
121-
}
122-
123114
phpvm_echo "=> phpvm has been installed to $BIN_DIR and is now globally available."
124115
}
125116

@@ -156,13 +147,11 @@ EOL
156147
inject_phpvm_config() {
157148
local PHPVM_PROFILE
158149
PHPVM_PROFILE="$(phpvm_detect_profile)"
159-
local PROFILE_INSTALL_DIR
160-
PROFILE_INSTALL_DIR="$(phpvm_install_dir | command sed "s:^$HOME:\$HOME:")"
161150

162151
PHPVM_CONFIG_STR="
163-
# Load PHPVM if it exists (similar to nvm)
152+
# Load PHPVM if it exists
164153
export PHPVM_DIR=\"\$HOME/.phpvm\"
165-
[[ -s \"\$PHPVM_DIR/phpvm\" ]] && source \"\$PHPVM_DIR/phpvm\"
154+
export PATH=\"\$HOME/.local/bin:\$PATH\"
166155
"
167156

168157
if [ -n "$PHPVM_PROFILE" ]; then

0 commit comments

Comments
 (0)