github.com/jenkins-x/test-infra@v0.0.7/hack/verify-spelling.sh (about)

     1  #!/usr/bin/env bash
     2  # Copyright 2018 The Kubernetes Authors.
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #     http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  set -o errexit
    17  set -o nounset
    18  set -o pipefail
    19  
    20  misspell=
    21  while getopts "m:" opt; do
    22    case "${opt}" in
    23      m)
    24        misspell="${OPTARG}"
    25        ;;
    26    esac
    27  done
    28  
    29  if [[ -z "${misspell}" ]]; then
    30    # Legacy non-Bazel mode. Maybe remove at some point?
    31    go install ./vendor/github.com/client9/misspell/cmd/misspell
    32    if ! which misspell >/dev/null 2>&1; then
    33      echo "Can't find misspell - is your GOPATH 'bin' in your PATH?"
    34      echo "  GOPATH: ${GOPATH}"
    35      echo "  PATH:   ${PATH}"
    36      exit 1
    37    fi
    38  
    39    git ls-files | grep -v -e vendor -e static -e third_party | xargs misspell -error
    40    exit
    41  fi
    42  
    43  find -L . -type f -not \( \
    44    \( \
    45      -path '*/vendor/*' \
    46      -o -path '*/static/*' \
    47      -o -path '*/third_party/*' \
    48      -o -path '*/node_modules/*' \
    49      \) -prune \
    50    \) | xargs "${misspell}" -error