Add initial support for custom sniffing
This commit is contained in:
@@ -68,6 +68,21 @@ function resolve_symlink() {
|
||||
echo "$out"
|
||||
}
|
||||
|
||||
function custom_sniff() {
|
||||
file="$1"
|
||||
|
||||
pr=$(project_root "$file")
|
||||
|
||||
if [[ -f "$pr/.would-reformat/custom-sniffer" ]]; then
|
||||
custom=$("$pr/.would-reformat/custom-sniffer" "$1")
|
||||
ret="$?"
|
||||
|
||||
echo "$custom"
|
||||
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
function custom_formatter() {
|
||||
root="$1"
|
||||
file_type="$2"
|
||||
@@ -88,6 +103,12 @@ function sniff_file_type() {
|
||||
ff=$1
|
||||
shift
|
||||
|
||||
maybe_custom=$(custom_sniff "$ff")
|
||||
if [[ "$maybe_custom" != "" ]]; then
|
||||
echo "$maybe_custom"
|
||||
return 0
|
||||
fi
|
||||
|
||||
file_type=
|
||||
|
||||
if [[ $ff == *.py ]]; then
|
||||
@@ -118,6 +139,8 @@ function sniff_file_type() {
|
||||
file_type="golang"
|
||||
elif [[ $ff = *.dart ]]; then
|
||||
file_type="dart"
|
||||
elif [[ $ff = *.pl ]]; then
|
||||
file_type="perl"
|
||||
fi
|
||||
|
||||
echo $file_type
|
||||
|
||||
Reference in New Issue
Block a user