Files
purchases-ios/scripts/swiftlint.sh
T
NachoSoto d8cbae0e1a SwiftLint: cleaned up output (#1821)
The output of `SwiftLint` is pretty noisy, which sometimes makes it hard to see other build warnings or errors in Xcode:

<img width="664" alt="Screenshot 2022-08-12 at 12 23 31" src="https://user-images.githubusercontent.com/685609/184502439-09881cff-df2b-424d-9d3e-96b238e8c45a.png">

This removes the "Linting... " lines when ran from Xcode.
2022-08-15 12:44:42 -07:00

32 lines
957 B
Bash
Executable File

#!/usr/bin/env bash
# Arm64 macs have this destination.
HOMEBREW_BINARY_DESTINATION="/opt/homebrew/bin"
if ! test -d $HOMEBREW_BINARY_DESTINATION; then
# X86_64 macs have this destination
HOMEBREW_BINARY_DESTINATION="/usr/local/bin"
fi
echo "Adding homebrew bin folder to PATH (${HOMEBREW_BINARY_DESTINATION})"
PATH="${HOMEBREW_BINARY_DESTINATION}:${PATH}"
if which swiftlint >/dev/null; then
script_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source_path="${script_path}/../"
swiftlint_path="$(which swiftlint)"
echo "linter path:"
echo $swiftlint_path
lint_command="${swiftlint_path} lint"
echo "linter command: ${lint_command}"
pushd "${source_path}"
# Run swiftlint but filter out "Linting ..." to clean up output
$lint_command 2>&1 | grep -v 'Linting '
popd
else
echo "Warning: SwiftLint not installed in ${HOMEBREW_BINARY_DESTINATION}, download from https://github.com/realm/SwiftLint"
fi