Skip to content

Commit

Permalink
Add legacy file support for .php-version
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Pöche committed Feb 10, 2023
1 parent 306793c commit 7dd8290
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bin/list-legacy-filenames
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

echo ".php-version"
18 changes: 18 additions & 0 deletions bin/parse-legacy-file
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"

0 comments on commit 7dd8290

Please sign in to comment.