Skip to content

Commit

Permalink
some fixes for build.sh (#1901)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss authored Nov 29, 2023
1 parent a4bfecb commit cef926d
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -o nounset
source_dirs="cmd pkg test lib tools"

# Store for later
if [ -z "$1" ]; then
if [ -z "${1-}" ]; then
ARGS=("")
else
ARGS=("$@")
Expand All @@ -47,6 +47,12 @@ run() {
exit 0
fi

# Run linter if requested
if has_flag --lint; then
source_lint
exit 0
fi

if has_flag --watch -w; then
# Build and test first
go_build
Expand Down Expand Up @@ -104,9 +110,6 @@ codegen() {
# Format source code and cleanup imports
source_format

# Lint source code
(( ! IS_PROW )) && source_lint

# Check for license headers
check_license

Expand All @@ -117,13 +120,13 @@ codegen() {

go_fmt() {
echo "🧹 ${S}Format"
find "$(echo "$source_dirs")" -name "*.go" -print0 | xargs -0 gofmt -s -w
find $(echo "$source_dirs") -name "*.go" -print0 | xargs -0 gofmt -s -w
}

source_format() {
set +e
go_run "golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION}" -w "$(echo "$source_dirs")"
find "$(echo "$source_dirs")" -name "*.go" -print0 | xargs -0 gofmt -s -w
go_run "golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION}" -w $(echo "$source_dirs")
find $(echo "$source_dirs") -name "*.go" -print0 | xargs -0 gofmt -s -w
set -e
}

Expand Down Expand Up @@ -198,7 +201,11 @@ check_license() {

update_deps() {
echo "🚒 Update"
"$(basedir)"/hack/update-deps.sh
if has_flag --verbose; then
"$(basedir)"/hack/update-deps.sh
else
"$(basedir)"/hack/update-deps.sh 1>/dev/null 2>&1
fi
}

generate_docs() {
Expand Down Expand Up @@ -334,6 +341,7 @@ with the following options:
-w --watch Watch for source changes and recompile in fast mode
-x --all Only build cross platform binaries without code-generation/testing
-h --help Display this help message
--lint Run the code linter
--verbose More output
--debug Debug information for this script (set -x)
Expand Down

0 comments on commit cef926d

Please sign in to comment.