提交 b0abaa99 编写于 作者: S storypku 提交者: Chang Songhong

Scripts: use mdfmt to format json/md/yml also

上级 792fa0bd
......@@ -39,13 +39,19 @@ function check_if_tools_installed() {
function format_markdown_by_prettier() {
for mypath in "$@"; do
if [ -d "${mypath}" ]; then
find "${mypath}" -type f -name "*.md" -exec npx prettier --write {} +
elif [[ -f "${mypath}" && "${mypath##*.}" == "md" ]]; then
npx prettier --write "${mypath}"
find "${mypath}" -type f \( -name "*.md" \
-or -name "*.json" \
-or -name "*.yml" \) \
-exec npx prettier --write {} +
elif [ -f "${mypath}" ]; then
local ext="${mypath##*.}"
if [[ "${ext}" == "md" || "${ext}" == "yml" || "${ext}" == "json" ]]; then
npx prettier --write "${mypath}"
else
warning "Only regular md/json/yml files will be formatted. Ignored ${mypath}"
fi
else
warning "Only regular markdown files with '.md' extension will be" \
"formatted, Got: ${mypath}"
exit 1
warning "Special/Symlink file won't be formatted. Ignored ${mypath}"
fi
done
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册