Skip to content
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions scripts/bats/bats
Submodule bats added at f7defb
16 changes: 14 additions & 2 deletions shell/linters/protobuf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,34 @@
# shellcheck disable=SC2034
extensions=(proto)

load_tool() {
"$DIR/gobin.sh" -p github.com/bufbuild/buf/cmd/buf@v"$(get_tool_version "buf")"
}

buf_linter() {
# Why: We're OK with this.
# shellcheck disable=SC2155
local PROTOFMT=$("$DIR/gobin.sh" -p github.com/bufbuild/buf/cmd/buf@v"$(get_tool_version "buf")")
local PROTOFMT=$(load_tool)
find_files_with_extensions "${extensions[@]}" | xargs -n1 "$PROTOFMT" format --exit-code --diff
}

buf_formatter() {
# Why: We're OK with this.
# shellcheck disable=SC2155
local PROTOFMT=$("$DIR/gobin.sh" -p github.com/bufbuild/buf/cmd/buf@v"$(get_tool_version "buf")")
local PROTOFMT=$(load_tool)
find_files_with_extensions "${extensions[@]}" | xargs -n1 "$PROTOFMT" format -w
}

buf_lint_linter() {
# Why: We're OK with this.
# shellcheck disable=SC2155
local PROTOFMT=$(load_tool)
find_files_with_extensions "${extensions[@]}" | xargs -n1 "$PROTOFMT" lint --path
}

linter() {
run_command "buf" buf_linter
run_command "buf" buf_lint_linter
}

formatter() {
Expand Down