Skip to content

Commit 57b5956

Browse files
authored
Fix code review comments (#103)
1 parent b6978e5 commit 57b5956

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

scripts/golangci-lint.sh

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
1-
#!/usr/bin/env bash
2-
3-
# prints error if a specific command does not exist
4-
function panic_if_command_not_exists() {
5-
if ! command -v "$1" >>/dev/null 2>/dev/null; then
6-
echo -e "\033[0;33m$1\033[0m command is not available - please install it first"
7-
exit 1
8-
fi
9-
}
1+
#!/bin/bash
2+
set -euo pipefail
103

114
# installs the golangci-lint of the specific version to the specific directory
125
function install_golangci_lint() {
136
local version="$1"
7+
local project_dir="." # cd "$(git rev-parse --show-toplevel)"
148

159
# check presence and version of golangci-lint
16-
if [[ -f third_party/golangci-lint ]]; then
10+
if [[ -f "$project_dir/third_party/golangci-lint" ]]; then
1711
local installed_version
18-
installed_version=$(third_party/golangci-lint --version | grep -E -o '[0-9]+\.[0-9]+\.[0-9]+')
12+
installed_version=$("$project_dir/third_party/golangci-lint" --version | grep -E -o '[0-9]+\.[0-9]+\.[0-9]+')
1913
if [[ $installed_version == "$version" ]]; then
2014
exit 0
2115
fi
2216
echo "golangci version is not as expected - got '$installed_version', want '$version' - will update"
2317
fi
2418

25-
panic_if_command_not_exists "curl"
26-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "./third_party" "v$version"
27-
}
19+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$project_dir/third_party" "v$version"
20+
}

third_party/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
golangci-lint
1+
golangci-lint

0 commit comments

Comments
 (0)