Try to do a few things

FIXME: do them correctly; squash and reword this travesty of a commit.
This commit is contained in:
Michael Wolf
2024-04-03 11:26:50 -06:00
parent 1957698fc4
commit 7c503cecf7
3 changed files with 31 additions and 5 deletions

View File

@@ -1,3 +1,11 @@
function log () {
msg=$@
if [[ ! -z "${LOG_TO+}" ]] ; then
echo "$msg" >> $LOG_TO
fi
}
function get_os() {
un=$(uname)
@@ -139,12 +147,13 @@ function sniff_file_type() {
file_type="css"
elif [[ $ff == *.scss ]]; then
file_type="scss"
elif [[ $ff = *.sh ]]; then
file_type="sh"
elif [[ $ff = *.go ]]; then
file_type="golang"
elif [[ $ff = *.dart ]]; then
file_type="dart"
elif [[ $ff = *.sh ]]; then
# .sh isn't enough; we'll need other extns
file_type="shell"
elif [[ $ff = *.pl ]]; then
file_type="perl"
elif [[ $ff = *.rs ]] ; then
@@ -186,8 +195,7 @@ function choose_wrapper() {
$file_type = "jsx" ||
$file_type = "tsx" ||
$file_type == "css" ||
$file_type == "scss" ||
$file_type = "sh" ]]; then
$file_type == "scss" ]]; then
out="$WF_ROOT"/./prettier.sh
elif [[ $file_type == "python" ]]; then
out="$WF_ROOT"/./isort-and-black.sh
@@ -197,6 +205,8 @@ function choose_wrapper() {
out="$WF_ROOT"/./rustfmt.sh
elif [[ $file_type == "dart" ]]; then
out="$WF_ROOT"/./dart_format.sh
elif [[ $file_type == "shell" ]] ; then
out="$WF_ROOT"/./shfmt.sh
else
out="$WF_ROOT"/./default.sh
fi

View File

@@ -7,6 +7,8 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$DIR/_reformat-common.bash"
#export LOG_DEST="$LOG_TO"
file="$1"
PROJECT_ROOT=$(project_root "$file")

View File

@@ -10,6 +10,12 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# wrflog before sourcing common funcs, I think i am in dir: $(pwd)
source "$DIR/_reformat-common.bash"
#export LOG_DEST="$LOG_TO"
log "is this thing on"
log i think it is on
file="$1"
PROJECT_ROOT=$(project_root "$file")
export PROJECT_ROOT="$PROJECT_ROOT"
@@ -24,11 +30,19 @@ export WOULD_REFORMAT=would_reformat
wrapper=$(choose_wrapper "$file_type")
log wrapper is "$wrapper"
set +e
echo asdf
out=$("$wrapper" "$file" 2>&1 >/dev/null)
retval="$?"
echo fdsa
set -e
echo retval "$retval"
success_retval=0
would_reformat_retval=1
syntax_error_retval=2