mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 23:11:14 -03:00
build_tools/style.fish: fail if formatters are not available
build_tools/check.sh is supposed to fail on formatting violations. I don't think we have a good reason for running build_tools/style.fish outside check.sh. black is the only formatter not versioned in CI -- but we can probably satisfy all realistic versions. Ref: https://github.com/fish-shell/fish-shell/pull/11608#discussion_r2173176621
This commit is contained in:
@@ -62,17 +62,16 @@ if set -q fish_files[1]
|
|||||||
if not type -q fish_indent
|
if not type -q fish_indent
|
||||||
echo
|
echo
|
||||||
echo $yellow'Could not find `fish_indent` in `$PATH`.'$normal
|
echo $yellow'Could not find `fish_indent` in `$PATH`.'$normal
|
||||||
echo
|
exit 127
|
||||||
else
|
end
|
||||||
echo === Running "$green"fish_indent"$normal"
|
echo === Running "$green"fish_indent"$normal"
|
||||||
if set -l -q _flag_check
|
if set -l -q _flag_check
|
||||||
if not fish_indent --check -- $fish_files
|
if not fish_indent --check -- $fish_files
|
||||||
echo $red"Fish files are not formatted correctly."$normal
|
echo $red"Fish files are not formatted correctly."$normal
|
||||||
exit 1
|
exit 1
|
||||||
end
|
|
||||||
else
|
|
||||||
fish_indent -w -- $fish_files
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
fish_indent -w -- $fish_files
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -80,17 +79,16 @@ if set -q python_files[1]
|
|||||||
if not type -q black
|
if not type -q black
|
||||||
echo
|
echo
|
||||||
echo $yellow'Please install `black` to style python'$normal
|
echo $yellow'Please install `black` to style python'$normal
|
||||||
echo
|
exit 127
|
||||||
else
|
end
|
||||||
echo === Running "$green"black"$normal"
|
echo === Running "$green"black"$normal"
|
||||||
if set -l -q _flag_check
|
if set -l -q _flag_check
|
||||||
if not black --check $python_files
|
if not black --check $python_files
|
||||||
echo $red"Python files are not formatted correctly."$normal
|
echo $red"Python files are not formatted correctly."$normal
|
||||||
exit 1
|
exit 1
|
||||||
end
|
|
||||||
else
|
|
||||||
black $python_files
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
black $python_files
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -98,30 +96,29 @@ if not cargo fmt --version >/dev/null
|
|||||||
echo
|
echo
|
||||||
echo $yellow'Please install "rustfmt" to style Rust, e.g. via:'
|
echo $yellow'Please install "rustfmt" to style Rust, e.g. via:'
|
||||||
echo "rustup component add rustfmt"$normal
|
echo "rustup component add rustfmt"$normal
|
||||||
echo
|
exit 127
|
||||||
else
|
end
|
||||||
echo === Running "$green"rustfmt"$normal"
|
echo === Running "$green"rustfmt"$normal"
|
||||||
if set -l -q _flag_check
|
if set -l -q _flag_check
|
||||||
if set -l -q _flag_all
|
if set -l -q _flag_all
|
||||||
if not cargo fmt --check
|
if not cargo fmt --check
|
||||||
echo $red"Rust files are not formatted correctly."$normal
|
echo $red"Rust files are not formatted correctly."$normal
|
||||||
exit 1
|
exit 1
|
||||||
end
|
|
||||||
else
|
|
||||||
if set -q rust_files[1]
|
|
||||||
if not rustfmt --check --files-with-diff $rust_files
|
|
||||||
echo $red"Rust files are not formatted correctly."
|
|
||||||
exit 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if set -l -q _flag_all
|
if set -q rust_files[1]
|
||||||
cargo fmt
|
if not rustfmt --check --files-with-diff $rust_files
|
||||||
else
|
echo $red"Rust files are not formatted correctly."
|
||||||
if set -q rust_files[1]
|
exit 1
|
||||||
rustfmt $rust_files
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if set -l -q _flag_all
|
||||||
|
cargo fmt
|
||||||
|
else
|
||||||
|
if set -q rust_files[1]
|
||||||
|
rustfmt $rust_files
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user