1
0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-12 19:18:28 +02:00

Fix error in laravel_version when artisan is not present

This commit is contained in:
Brandon Clothier 2018-07-14 18:24:10 -04:00
parent a7b3f310d3
commit 48b264f564
No known key found for this signature in database
GPG Key ID: D71A0436ED3153AD
2 changed files with 8 additions and 8 deletions

View File

@ -1118,11 +1118,10 @@ prompt_vpn_ip() {
################################################################
# Segment to display laravel version
prompt_laravel_version() {
local laravel_version="$(php artisan --version 2>/dev/null)"
local laravel_version="$(php artisan --version 2>&1 | grep -oe '^Laravel Framework [0-9.]*')"
if [[ -n "${laravel_version}" ]]; then
# Remove unrelevant infos
laravel_version="${laravel_version//Laravel Framework version /}"
# Strip out everything but the version
laravel_version="${laravel_version//Laravel Framework /}"
"$1_prompt_segment" "$0" "$2" "maroon" "white" "${laravel_version}" 'LARAVEL_ICON'
fi
}

View File

@ -14,16 +14,17 @@ function setUp() {
function mockLaravelVersion() {
case "$1" in
"artisan")
echo "Laravel Framework version 5.4.23"
# artisan --version follows the format Laravel Framework <version>
echo "Laravel Framework 5.4.23"
;;
default)
esac
}
function mockNoLaravelVersion() {
# This should output some error
>&2 echo "Artisan not available"
return 1
# When php can't find a file it will output a message
echo "Could not open input file: artisan"
return 0
}
function testLaravelVersionSegment() {