From 504105eae998f2462d1af0fd7079122597e26095 Mon Sep 17 00:00:00 2001 From: Jerome Thayananthajothy Date: Sun, 6 Oct 2024 15:18:55 +0100 Subject: [PATCH] Refactor install.sh to add global symlink for phpvm --- bin/install.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/install.sh b/bin/install.sh index fdcffb4..e3ff8c5 100644 --- a/bin/install.sh +++ b/bin/install.sh @@ -87,6 +87,7 @@ } phpvm_create_launcher + phpvm_create_symlink } phpvm_create_launcher() { @@ -106,6 +107,19 @@ EOL chmod +x "$INSTALL_DIR/bin/phpvm" } + phpvm_create_symlink() { + local INSTALL_DIR + INSTALL_DIR="$(phpvm_install_dir)" + + # Create a global symlink for phpvm + if [ -d "/usr/local/bin" ]; then + sudo ln -sf "$INSTALL_DIR/bin/phpvm" /usr/local/bin/phpvm + phpvm_echo "=> Created a global symlink for phpvm at /usr/local/bin/phpvm" + else + phpvm_echo "=> /usr/local/bin not found, please ensure it's in your PATH" + fi + } + phpvm_detect_profile() { if [ "${PROFILE-}" = '/dev/null' ]; then return @@ -141,7 +155,6 @@ EOL PROFILE_INSTALL_DIR="$(phpvm_install_dir | command sed "s:^$HOME:\$HOME:")" PHPVM_CONFIG_STR=" -# Load PHPVM if it exists (similar to nvm) [[ -s \"\$PHPVM_DIR/index.js\" ]] && export PATH=\"\$PHPVM_DIR/bin:\$PATH\" && node \"\$PHPVM_DIR/index.js\" "