diff --git a/bin/list-legacy-filenames b/bin/list-legacy-filenames new file mode 100755 index 0000000..0b5f32a --- /dev/null +++ b/bin/list-legacy-filenames @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +echo ".php-version" diff --git a/bin/parse-legacy-file b/bin/parse-legacy-file new file mode 100755 index 0000000..a8066c5 --- /dev/null +++ b/bin/parse-legacy-file @@ -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"