Skip to content

Commit

Permalink
fix: Correct yamllint's existence check
Browse files Browse the repository at this point in the history
`command -v <cmd>` returns a path to binary to stdout if it's found in PATH.
The condition deciding if yamllint is installed redirects stdout to `/dev/null`
and so this check could never work.

This change redirects stderr instead of stdout to compare the output of
`command -v <cmd>` properly with an empty string.

I unified the redirection to a file in whole file. The empty space behind
redirection is not needed.
  • Loading branch information
pulecp committed Nov 3, 2023
1 parent a45f3e1 commit 7940d28
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ endif
GOTEST := $(GO) test
GOTEST_DIR :=
ifneq ($(CIRCLE_JOB),)
ifneq ($(shell command -v gotestsum > /dev/null),)
ifneq ($(shell command -v gotestsum 2>/dev/null),)
GOTEST_DIR := test-results
GOTEST := gotestsum --junitfile $(GOTEST_DIR)/unit-tests.xml --
endif
Expand Down Expand Up @@ -171,14 +171,14 @@ ifdef GOLANGCI_LINT
@echo ">> running golangci-lint"
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
# Otherwise staticcheck might fail randomly for some reason not yet explained.
$(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
$(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... >/dev/null
$(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
endif

.PHONY: common-yamllint
common-yamllint:
@echo ">> running yamllint on all YAML files in the repository"
ifeq (, $(shell command -v yamllint > /dev/null))
ifeq ($(shell command -v yamllint 2>/dev/null),)
@echo "yamllint not installed so skipping"
else
yamllint .
Expand Down

0 comments on commit 7940d28

Please sign in to comment.