Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace RBENV_VERSION with PHPENV_VERSION variable (Depends on fix-update) #43

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions bin/phpenv-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ update_phpenv() {
local cwd=$(pwd)
cd "$install_location"

git pull origin master &> /dev/null
git checkout .
git pull origin master

cd "$cwd"
}
Expand All @@ -58,6 +59,20 @@ clone_rbenv() {
git clone "$RBENV_REPO" "$install_location" > /dev/null
}

replace_rbenv() {
local install_location="$1"

sed -i -e 's/rbenv/phpenv/g' "$install_location"/completions/rbenv.{bash,zsh}
sed -i -s 's/\.rbenv-version/.phpenv-version/g' "$install_location"/libexec/rbenv-local
sed -i -s 's/\.rbenv-version/.phpenv-version/g' "$install_location"/libexec/rbenv-version-file
sed -i -s 's/\.ruby-version/.php-version/g' "$install_location"/libexec/rbenv-local
sed -i -s 's/\.ruby-version/.php-version/g' "$install_location"/libexec/rbenv-version-file
sed -i -e 's/\(^\|[^/]\)rbenv/\1phpenv/g' "$install_location"/libexec/rbenv-init
sed -i -e 's/\phpenv-commands/rbenv-commands/g' "$install_location"/libexec/rbenv-init
sed -i -e 's/\Ruby/PHP/g' "$install_location"/libexec/rbenv-which
sed -i -e 's/RBENV_VERSION/PHPENV_VERSION/g' "$PHPENV_ROOT"/libexec/rbenv-*
}

if [ -z "$PHPENV_ROOT" ]; then
PHPENV_ROOT="$HOME/.phpenv"
fi
Expand All @@ -69,18 +84,12 @@ fi
if [ "$UPDATE" = "yes" ]; then
echo "Updating phpenv in $PHPENV_ROOT"
update_phpenv "$PHPENV_ROOT"
replace_rbenv "$PHPENV_ROOT"
else
echo "Installing phpenv in $PHPENV_ROOT"
if [ "$CHECKOUT" = "yes" ]; then
clone_rbenv "$PHPENV_ROOT"
sed -i -e 's/rbenv/phpenv/g' "$PHPENV_ROOT"/completions/rbenv.{bash,zsh}
sed -i -s 's/\.rbenv-version/.phpenv-version/g' "$PHPENV_ROOT"/libexec/rbenv-local
sed -i -s 's/\.rbenv-version/.phpenv-version/g' "$PHPENV_ROOT"/libexec/rbenv-version-file
sed -i -s 's/\.ruby-version/.php-version/g' "$PHPENV_ROOT"/libexec/rbenv-local
sed -i -s 's/\.ruby-version/.php-version/g' "$PHPENV_ROOT"/libexec/rbenv-version-file
sed -i -e 's/\(^\|[^/]\)rbenv/\1phpenv/g' "$PHPENV_ROOT"/libexec/rbenv-init
sed -i -e 's/\phpenv-commands/rbenv-commands/g' "$PHPENV_ROOT"/libexec/rbenv-init
sed -i -e 's/\Ruby/PHP/g' "$PHPENV_ROOT"/libexec/rbenv-which
replace_rbenv "$PHPENV_ROOT"
fi
fi

Expand Down