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

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

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