From 2df1a1c82c9ff26091faccf55aea6b943687d857 Mon Sep 17 00:00:00 2001 From: Russell Rollins Date: Tue, 17 Jun 2025 09:03:02 -0400 Subject: [PATCH] Use monorepo-diff-buildkite-plugin from the PATH if available. --- hooks/command | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hooks/command b/hooks/command index cc35b04..bcc0aef 100755 --- a/hooks/command +++ b/hooks/command @@ -96,18 +96,25 @@ download_binary_and_run() { fi local test_mode="${BUILDKITE_PLUGIN_MONOREPO_DIFF_BUILDKITE_PLUGIN_TEST_MODE:-false}" + local _command="./${_executable}" if [[ "$test_mode" == "false" ]]; then - if ! downloader "$_url" "$_executable"; then - say "failed to download $_url" - exit 1 + # If the command is already available, use it where in the PATH it is. + # Otherwise, download the binary and make it executable. + if check_cmd monorepo-diff-buildkite-plugin; then + _command="$(command -v monorepo-diff-buildkite-plugin)" + else + if ! downloader "$_url" "$_executable"; then + say "failed to download $_url" + exit 1 + fi + + # todo: move it to a more secure place + chmod +x ${_executable} fi fi - - # todo: move it to a more secure place - chmod +x ${_executable} - ./${_executable} + ./${_command} } download_binary_and_run "$@" || exit 1