-
Notifications
You must be signed in to change notification settings - Fork 280
/
Copy pathformat
executable file
·37 lines (31 loc) · 1.31 KB
/
format
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/zsh -Ndefgku
#
# script/format
# mas
#
# Automatically formats and fixes style violations using various tools.
#
# Please keep in sync with script/lint.
#
. "${0:a:h}/_setup_script"
printf $'==> 🧹 Formatting mas %s\n' "$(script/version)"
for formatter in markdownlint prettier swift-format swiftformat swiftlint yamllint; do
if ! command -v "${formatter}" >/dev/null; then
printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${formatter}" "${formatter}" >&2
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}"
script -q /dev/null swiftformat --strict "${source}" |
(grep -vxE '(?:\^D\x08{2})?Running SwiftFormat\.{3}\r|Reading (?:config|swift-version) file at .*|\x1b\[32mSwiftFormat completed in \d+\.\d+s\.\x1b\[0m\r|0/\d+ files formatted\.\r' || true)
printf -- $'--> 🦅 %s swiftlint\n' "${source}"
swiftlint --fix --quiet "${source}"
done
printf -- $'--> 〽️ Markdown\n'
markdownlint --config .markdownlint.json --fix . docs
printf -- $'--> 📝 YAML\n'
script -q /dev/null prettier --write "${(f)"$(yamllint --list-files .)"}" |
(grep -vxE '.+ \d+ms \(unchanged\)\r' || true)