Initial import
This commit is contained in:
38
do-reformat.sh
Executable file
38
do-reformat.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -uo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$DIR/_reformat-common.sh"
|
||||
|
||||
file="$1"
|
||||
|
||||
file_type=$(sniff_file_type $file)
|
||||
|
||||
if [[ $file_type == "javascript" || \
|
||||
$file_type == "vue" || \
|
||||
$file_type == "css" || \
|
||||
$file_type == "typescript" || \
|
||||
$file_type == "php" ]] ; then
|
||||
out=$(npx prettier --write $file)
|
||||
retval="$?"
|
||||
success_retval=0
|
||||
elif [[ $file_type == "python" ]] ; then
|
||||
out=$(pipx run black $file 2>/dev/null)
|
||||
retval="$?"
|
||||
success_retval=0
|
||||
else
|
||||
echo -n "ignoring"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ x"$retval" == x"$success_retval" ]] ; then
|
||||
echo "$out"
|
||||
exit 0
|
||||
else
|
||||
exit $retval
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user