Skip to content

Commit 7dd8290

Browse files
author
Sven Pöche
committed
Add legacy file support for .php-version
1 parent 306793c commit 7dd8290

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

bin/list-legacy-filenames

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
echo ".php-version"

bin/parse-legacy-file

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
get_legacy_version() {
4+
current_file="$1"
5+
basename="$(basename -- "$current_file")"
6+
7+
if [ "$basename" == ".php-version" ]; then
8+
# Get version from .php-version file (filters out 'php-' prefix if it exists).
9+
# The .php-version is used by rbenv and now rvm.
10+
php_version="$(cat "$current_file")"
11+
php_prefix="php-"
12+
PHP_VERSION="${php_version/#$php_prefix/}"
13+
fi
14+
15+
echo "$PHP_VERSION"
16+
}
17+
18+
get_legacy_version "$1"

0 commit comments

Comments
 (0)