-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add legacy file support for .php-version
- Loading branch information
Sven Pöche
committed
Feb 10, 2023
1 parent
306793c
commit 7dd8290
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo ".php-version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
get_legacy_version() { | ||
current_file="$1" | ||
basename="$(basename -- "$current_file")" | ||
|
||
if [ "$basename" == ".php-version" ]; then | ||
# Get version from .php-version file (filters out 'php-' prefix if it exists). | ||
# The .php-version is used by rbenv and now rvm. | ||
php_version="$(cat "$current_file")" | ||
php_prefix="php-" | ||
PHP_VERSION="${php_version/#$php_prefix/}" | ||
fi | ||
|
||
echo "$PHP_VERSION" | ||
} | ||
|
||
get_legacy_version "$1" |