github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/hack/verify-spelling.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -o errexit
     4  set -o nounset
     5  set -o pipefail
     6  
     7  TOOL_VERSION="v0.3.4"
     8  
     9  # cd to the root path
    10  ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
    11  cd "${ROOT}"
    12  
    13  # create a temporary directory
    14  TMP_DIR=$(mktemp -d)
    15  
    16  # cleanup
    17  exitHandler() (
    18    echo "Cleaning up..."
    19    rm -rf "${TMP_DIR}"
    20  )
    21  trap exitHandler EXIT
    22  
    23  # perform go get in a temp dir as we are not tracking this version in a go module
    24  # if we do the go get in the repo, it will create / update a go.mod and go.sum
    25  cd "${TMP_DIR}"
    26  GO111MODULE=on GOBIN="${TMP_DIR}" go install "github.com/client9/misspell/cmd/misspell@${TOOL_VERSION}"
    27  export PATH="${TMP_DIR}:${PATH}"
    28  cd "${ROOT}"
    29  
    30  # check spelling
    31  RES=0
    32  echo "Checking spelling..."
    33  ERROR_LOG="${TMP_DIR}/errors.log"
    34  git ls-files | grep -v vendor | xargs misspell > "${ERROR_LOG}"
    35  if [[ -s "${ERROR_LOG}" ]]; then
    36    sed 's/^/error: /' "${ERROR_LOG}" # add 'error' to each line to highlight in e2e status
    37    echo "Found spelling errors!"
    38    RES=1
    39  fi
    40  exit "${RES}"