mirror of
https://github.com/mas-cli/mas
synced 2024-11-25 21:10:24 +00:00
e9fcf2b254
Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> # Manual Merge Cleanup: # .actrc # .github/workflows/pr-checks.yml # .github/workflows/release.yml # Brewfile # script/test # script/version_bump # Conflicts: # .github/workflows/build-test.yml # .gitignore # .swiftlint.yml # Brewfile.lock.json # Package.resolved # Sources/mas/Package.swift # Tests/masTests/.swiftlint.yml # script/bootstrap # script/build # script/format # script/lint # script/uninstall # script/version
51 lines
1.3 KiB
Bash
Executable file
51 lines
1.3 KiB
Bash
Executable file
#!/bin/bash -eu
|
|
#
|
|
# script/format
|
|
# mas
|
|
#
|
|
# Linting checks for development and CI.
|
|
#
|
|
# Automatically formats and fixes style violations using various tools.
|
|
#
|
|
# Please keep in sync with script/lint.
|
|
#
|
|
|
|
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
|
|
|
|
if ! cd -- "${mas_dir}"; then
|
|
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
printf $'==> 🚨 Formatting mas\n'
|
|
|
|
for LINTER in markdownlint prettier shfmt swift-format swiftformat swiftlint yamllint; do
|
|
if [[ ! -x "$(command -v ${LINTER})" ]]; then
|
|
printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${LINTER}" "${LINTER}"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
for SOURCE in Package.swift Sources Tests; do
|
|
printf -- $'--> 🕊 %s swift-format\n' "${SOURCE}"
|
|
swift-format format --in-place --recursive "${SOURCE}"
|
|
printf -- $'--> 🕊 %s swiftformat\n' "${SOURCE}"
|
|
swiftformat "${SOURCE}"
|
|
printf -- $'--> 🕊 %s swiftlint\n' "${SOURCE}"
|
|
swiftlint --fix --strict "${SOURCE}"
|
|
done
|
|
|
|
printf -- $'--> 📜 Bash shfmt\n'
|
|
shfmt \
|
|
--write \
|
|
--list \
|
|
--indent 2 \
|
|
--case-indent \
|
|
contrib/ script/
|
|
|
|
printf -- $'--> 〽️ Markdown\n'
|
|
markdownlint --config .markdownlint.json --fix .github .
|
|
|
|
printf -- $'--> 🖊 YAML\n'
|
|
# shellcheck disable=SC2046
|
|
prettier --write $(yamllint --list-files .)
|