Add ability to check formatting

This commit is contained in:
Utku Demir 2022-10-24 12:25:49 +13:00
parent b99dc4c04f
commit 1d0c76d422
2 changed files with 17 additions and 4 deletions

View File

@ -38,6 +38,7 @@
pkgs.haskellPackages.ormolu
pkgs.haskellPackages.hlint
pkgs.nixpkgs-fmt
pkgs.bash
];
withHoogle = false;
};

View File

@ -1,7 +1,19 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
if [[ "$1" == "check" ]]; then
ormolu_flags="--mode check"
nixpkgs_fmt_flags="--check"
elif [[ "$1" == "format" ]]; then
ormolu_flags="--mode inplace"
nixpkgs_fmt_flags=""
else
echo "Usage: $0 [check|format]"
exit 1
fi
set -o xtrace
set -o errexit
shopt -s globstar
set -o xtrace
fd -e hs -X ormolu -o -XTypeApplications --mode inplace {}
nixpkgs-fmt default.nix shell.nix flake.nix
ormolu $ormolu_flags {src,test}/**/*.hs
nixpkgs-fmt $nixpkgs_fmt_flags default.nix shell.nix flake.nix