Run files through prettier; add rudimentary .sh support

This commit is contained in:
Michael Wolf
2020-08-12 14:03:26 -05:00
parent 91e86745a0
commit 4cda5e0951
3 changed files with 28 additions and 24 deletions

View File

@@ -21,6 +21,8 @@ function sniff_file_type() {
file_type="jsx"
elif [[ $ff == *.tsx ]]; then
file_type="tsx"
elif [[ $ff = *.sh ]]; then
file_type="sh"
fi
echo $file_type

View File

@@ -18,7 +18,8 @@ if [[ $file_type == "javascript" || \
$file_type == "php" || \
$file_type == "html" || \
$file_type == "jsx" || \
$file_type == "tsx" ]] ; then
$file_type == "tsx" || \
$file_type == "sh" ]]; then
out=$(npx prettier --write $file)
retval="$?"
success_retval=0

View File

@@ -11,14 +11,15 @@ source "$DIR/_reformat-common.sh"
file_type=$(sniff_file_type $file)
if [[ $file_type == "javascript" || \
$file_type == "vue" || \
$file_type == "typescript" || \
$file_type == "css" || \
$file_type == "php" || \
$file_type == "html" || \
$file_type == "jsx" || \
$file_type == "tsx" ]] ; then
if [[ $file_type = "javascript" || \
$file_type = "vue" || \
$file_type = "typescript" || \
$file_type = "css" || \
$file_type = "php" || \
$file_type = "html" || \
$file_type = "jsx" || \
$file_type = "tsx" || \
$file_type = "sh" ]]; then
out=$(npx prettier --check $file 2>&1 >/dev/null)
retval="$?"
success_retval=0