From a85ff2e8bba05eb7c59b170ac832e9393e1ac227 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 23 Jul 2020 09:45:48 +0100 Subject: [PATCH] Run phpunit or pest depending on the project Remove the `p` and `pf` aliases that previously only worked for PHPUnit, and re-add them as functions that run either PHPUnit or Pest PHP based on the project dependencies. The checking is done within the `phpunit-or-pest` script and then used within the new `p` and `pf` functions. --- bin/phpunit-or-pest | 8 ++++++++ tag-zsh/zsh/configs/aliases.zsh | 2 -- tag-zsh/zsh/configs/functions.zsh | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100755 bin/phpunit-or-pest diff --git a/bin/phpunit-or-pest b/bin/phpunit-or-pest new file mode 100755 index 0000000..781b712 --- /dev/null +++ b/bin/phpunit-or-pest @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if [[ -f "vendor/bin/pest" ]]; then + echo "pest" + exit 0 +fi + +echo "phpunit" diff --git a/tag-zsh/zsh/configs/aliases.zsh b/tag-zsh/zsh/configs/aliases.zsh index 678d0a5..a840741 100644 --- a/tag-zsh/zsh/configs/aliases.zsh +++ b/tag-zsh/zsh/configs/aliases.zsh @@ -2,8 +2,6 @@ alias c="clear" alias l="ls -lah" alias m=make alias mkdir="mkdir -p" -alias p=phpunit -alias pf=phpunit --filter alias s=symfony alias v=vagrant diff --git a/tag-zsh/zsh/configs/functions.zsh b/tag-zsh/zsh/configs/functions.zsh index 0a963f4..1f81ffe 100644 --- a/tag-zsh/zsh/configs/functions.zsh +++ b/tag-zsh/zsh/configs/functions.zsh @@ -21,3 +21,11 @@ function db { is_linux() { [[ "$(uname)" == 'Linux' ]] } is_macos() { [[ "$(uname)" == "Darwin" ]] } + +# Run 'phpunit' or 'pest' depending on the project. +function p () { + vendor/bin/$(phpunit-or-pest) $*; +} +function pf () { + vendor/bin/$(phpunit-or-pest) --filter $* +}