diff --git a/README.md b/README.md index 3e89d60..9f208fe 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Take the advantage of goodie commands like `phpctl create` to start a new projec - Docker ### Install -If you want to install it system-wide (at `/usr/local/bin`), run: +You can install with default installer script for a system-wide (at `/usr/local/bin`), run: ```shell wget -q https://phpctl.dev/phpctl-installer.sh && \ bash phpctl-installer.sh && rm phpctl-installer.sh @@ -43,12 +43,19 @@ bash phpctl-installer.sh && rm phpctl-installer.sh > bash phpctl-installer.sh ~/bin > ``` +Homebrew +`brew install opencodeco/phpctl/phpctl` + +Or add the `oppencodeco` tap with `brew tap opencodeco/phpctl` and then `brew install phpctl` + #### Update You can re-run the installer or use the `self-update` command: ```shell phpctl self-update ``` +For those using Homebrew `brew upgrade opencodeco/phpctl/phpctl` or when run `brew update` + ## Usage Then you can use `phpctl` or `pctl` with a subcommand: ```shell diff --git a/src/self-update.sh b/src/self-update.sh index 1f42cce..0a0b37a 100644 --- a/src/self-update.sh +++ b/src/self-update.sh @@ -1,6 +1,22 @@ +is_brew_installed() { + command -v brew >/dev/null 2>&1 +} + +is_tap_installed() { + local tap_name="$1" + brew tap | grep -q "^$tap_name$" +} + self-update() { + local tap_to_check="opencodeco/phpctl" + local full_tap_pkg="$tap_to_check/phpctl" + + if is_brew_installed && is_tap_installed "$tap_to_check"; then + echo -e "\033[32mSeems phpctl was installed by Homebrew, to update it run\033[0m brew upgrade $full_tap_pkg" + else echo -e "Heading to \033[33m$PHPCTL_DIR\033[0m to update..." cd "$PHPCTL_DIR" || exit 1 git pull origin HEAD echo -e "\033[32mUpdated!\033[0m" + fi }