Skip to content

Commit 14579fa

Browse files
authored
chore(Makefile): add shell safety to fmt/go (coder#15974)
This PR adds shell safety to `make fmt/go` as per coder#15971 (comment)
1 parent 6434199 commit 14579fa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,14 @@ RESET := $(shell tput sgr0 2>/dev/null)
417417
fmt: fmt/ts fmt/go fmt/terraform fmt/shfmt fmt/prettier
418418
.PHONY: fmt
419419

420-
GO_FMT_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go' -exec sh -c 'grep -L "DO NOT EDIT" "{}" 2>/dev/null || true' \;)
421-
422420
fmt/go:
423421
go mod tidy
424422
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/go$(RESET)"
425423
# VS Code users should check out
426424
# https://github.com/mvdan/gofumpt#visual-studio-code
427-
go run mvdan.cc/gofumpt@v0.4.0 -w -l $(GO_FMT_FILES)
425+
find . $(FIND_EXCLUSIONS) -type f -name '*.go' -print0 | \
426+
xargs -0 grep --null -L "DO NOT EDIT" | \
427+
xargs -0 go run mvdan.cc/gofumpt@v0.4.0 -w -l
428428
.PHONY: fmt/go
429429

430430
fmt/ts:

0 commit comments

Comments
 (0)