diff --git a/README.md b/README.md index 9c9c331..83e5a3c 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,11 @@ saving a file and to run `do-reformat.sh` when you hit ``. - css - cscc - sh +- dart -Python and go use `black` and `gofmt` respectively. The rest use `prettier`. -Adding new programming languages is easy, assuming they have a formatter with -a dry run mode. +Python uses `black`; go uses `gofmt`; dart uses `dart format`. The rest use +`prettier`. Adding new programming languages is easy, assuming they have a +formatter with a dry run mode. # Installation diff --git a/_reformat-common.sh b/_reformat-common.sh index 19152ff..b129897 100644 --- a/_reformat-common.sh +++ b/_reformat-common.sh @@ -29,6 +29,8 @@ function sniff_file_type() { file_type="sh" elif [[ $ff = *.go ]] ; then file_type="golang" + elif [[ $ff = *.dart ]] ; then + file_type="dart" fi echo $file_type diff --git a/do-reformat.sh b/do-reformat.sh index 042f0b9..497d53c 100755 --- a/do-reformat.sh +++ b/do-reformat.sh @@ -33,6 +33,10 @@ elif [[ $file_type == "golang" ]] ; then out=$(gofmt -w "$file" 2>/dev/null) retval="$?" success_retval=0 +elif [[ $file_type == "dart" ]] ; then + out=$(dart format $file) + retval="$?" + success_retval=0 else echo -n "ignoring" exit 0 diff --git a/would-reformat.sh b/would-reformat.sh index 96ab8ff..ebd39aa 100755 --- a/would-reformat.sh +++ b/would-reformat.sh @@ -58,6 +58,15 @@ elif [[ $file_type == "golang" ]] ; then # success retval="$exitval" fi +elif [[ $file_type == "dart" ]] ; then + success_retval=0 + would_reformat_retval=1 + # probably others too :( + syntax_error_retval=65 + + out=$(dart format -o none --set-exit-if-changed $file) + exitval="$?" + retval="$exitval" else echo -n "ignoring" exit 0