From 48b264f564c2322f4932da0d391fa98331ebc158 Mon Sep 17 00:00:00 2001 From: Brandon Clothier Date: Sat, 14 Jul 2018 18:24:10 -0400 Subject: [PATCH 1/3] Fix error in laravel_version when artisan is not present --- powerlevel9k.zsh-theme | 7 +++---- test/segments/laravel_version.spec | 9 +++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index f3126b81..6a2f0f5f 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -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 } diff --git a/test/segments/laravel_version.spec b/test/segments/laravel_version.spec index 40b130d2..6133b19a 100755 --- a/test/segments/laravel_version.spec +++ b/test/segments/laravel_version.spec @@ -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 + 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() { From ef1f29a5cb171c739f0dbf41e6dbfa1fb3558345 Mon Sep 17 00:00:00 2001 From: Brandon Clothier Date: Wed, 18 Jul 2018 11:45:05 -0400 Subject: [PATCH 2/3] Drop grep usage in favor of zsh regex test --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 6a2f0f5f..573f2f68 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1118,8 +1118,8 @@ prompt_vpn_ip() { ################################################################ # Segment to display laravel version prompt_laravel_version() { - local laravel_version="$(php artisan --version 2>&1 | grep -oe '^Laravel Framework [0-9.]*')" - if [[ -n "${laravel_version}" ]]; then + local laravel_version="$(php artisan --version 2> /dev/null" + if [[ -n "${laravel_version}" && "${laravel_version}" =~ "Laravel Framework" ]]; then # Strip out everything but the version laravel_version="${laravel_version//Laravel Framework /}" "$1_prompt_segment" "$0" "$2" "maroon" "white" "${laravel_version}" 'LARAVEL_ICON' From 9739c688942f82893dc2721983986425eb5852c5 Mon Sep 17 00:00:00 2001 From: Brandon Clothier Date: Sun, 22 Jul 2018 21:55:44 -0400 Subject: [PATCH 3/3] Missed a parenthesis here. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 573f2f68..8af3cb61 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1118,7 +1118,7 @@ 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> /dev/null)" if [[ -n "${laravel_version}" && "${laravel_version}" =~ "Laravel Framework" ]]; then # Strip out everything but the version laravel_version="${laravel_version//Laravel Framework /}"