Skip to content

Commit 757b0e1

Browse files
committed
Refactor install.sh to add phpvm_create_bin function
1 parent 31530db commit 757b0e1

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

bin/install.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,10 @@
2323
}
2424

2525
phpvm_latest_version() {
26-
# Fetch the latest version from GitHub
2726
latest_version=$(curl -s https://api.github.com/repos/Thavarshan/phpvm/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
28-
29-
# Default to main if the version is not found
3027
if [ -z "$latest_version" ]; then
3128
latest_version="main"
3229
fi
33-
3430
phpvm_echo "$latest_version"
3531
}
3632

@@ -84,6 +80,23 @@
8480
phpvm_echo >&2 'Failed to install Node.js dependencies. Please report this!'
8581
exit 1
8682
}
83+
84+
# Ensure the bin directory and executable exist
85+
phpvm_create_bin
86+
}
87+
88+
phpvm_create_bin() {
89+
local INSTALL_DIR
90+
INSTALL_DIR="$(phpvm_install_dir)"
91+
92+
# Create the bin directory if it doesn't exist
93+
mkdir -p "$INSTALL_DIR/bin"
94+
95+
# Create a symlink to the phpvm executable
96+
ln -sf "$INSTALL_DIR/index.js" "$INSTALL_DIR/bin/phpvm"
97+
98+
# Make the symlink executable
99+
chmod +x "$INSTALL_DIR/bin/phpvm"
87100
}
88101

89102
phpvm_detect_profile() {

0 commit comments

Comments
 (0)