From 75aabac5941f414b03946948d36669e1bd47b3f1 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Mon, 10 Oct 2022 08:48:50 -0400 Subject: [PATCH] Use existing goimports installation if available --- cmd/urfave-cli-genflags/Makefile | 3 +++ cmd/urfave-cli-genflags/main.go | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/urfave-cli-genflags/Makefile b/cmd/urfave-cli-genflags/Makefile index 95b932d..acede8e 100644 --- a/cmd/urfave-cli-genflags/Makefile +++ b/cmd/urfave-cli-genflags/Makefile @@ -1,6 +1,9 @@ +GOIMPORTS_BIN ?= $(shell which goimports || true) GOTEST_FLAGS ?= -v --coverprofile main.coverprofile --covermode count --cover github.com/urfave/cli/v2/cmd/urfave-cli-genflags GOBUILD_FLAGS ?= -x +export GOIMPORTS_BIN + .PHONY: all all: test build smoke-test diff --git a/cmd/urfave-cli-genflags/main.go b/cmd/urfave-cli-genflags/main.go index 7f8deb6..54cc83e 100644 --- a/cmd/urfave-cli-genflags/main.go +++ b/cmd/urfave-cli-genflags/main.go @@ -94,8 +94,9 @@ func main() { Value: "cli.", }, &cli.PathFlag{ - Name: "goimports", - Value: filepath.Join(top, ".local/bin/goimports"), + Name: "goimports", + EnvVars: []string{"GOIMPORTS_BIN"}, + Value: filepath.Join(top, ".local/bin/goimports"), }, }, Action: runGenFlags,