diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2018-07-23 21:34:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-23 21:34:00 +0300 |
commit | 571a859413866897cf962396f02f65a288f677ac (patch) | |
tree | bf4f078c9b76eb69f6a3bf162053a606f540f268 | |
parent | e70ce438096acab4c35c91fad1c088fb2dff6ae6 (diff) | |
parent | 9739c688942f82893dc2721983986425eb5852c5 (diff) |
Merge pull request #912 from brandon14/laravel_pormpt_fix
[Bugfix] Fix error in laravel_version when artisan is not present
-rwxr-xr-x | powerlevel9k.zsh-theme | 9 | ||||
-rwxr-xr-x | test/segments/laravel_version.spec | 9 |
2 files changed, 9 insertions, 9 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 73573a07..0b2287ef 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1130,11 +1130,10 @@ prompt_vpn_ip() { ################################################################ # Segment to display laravel version prompt_laravel_version() { - local laravel_version="$(php artisan --version 2>/dev/null)" - if [[ -n "${laravel_version}" ]]; then - # Remove unrelevant infos - laravel_version="${laravel_version//Laravel Framework version /}" - + 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' 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 <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() { |