Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions hooks/command
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,25 @@ download_binary_and_run() {
fi

local test_mode="${BUILDKITE_PLUGIN_MONOREPO_DIFF_BUILDKITE_PLUGIN_TEST_MODE:-false}"
local _command="./${_executable}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using this default value hides the fact that the variable is then used incorrectly unless the value is modified to remove the starting ./


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
Comment on lines +104 to +106
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a way to still force a download

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