diff --git a/sh/fmt b/sh/fmt new file mode 100755 index 000000000..c15ff4492 --- /dev/null +++ b/sh/fmt @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Usage: fmt + +# Run all formatters and linters ensuring codebase consistency + +set -euo pipefail + +cd "${0%/*}" + +./fmt-shell +./fmt-nix +./fmt-haskell + +echo 'Done.' diff --git a/sh/fmt-haskell b/sh/fmt-haskell new file mode 100755 index 000000000..6b5de6117 --- /dev/null +++ b/sh/fmt-haskell @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Usage: fmt-haskell + +set -euo pipefail + +cd "${0%/*}/.." + +echo "Formatting Haskell" + +# FIXME: Avoid inplace (-i) modifications for now. +find pkg/hs -type f -name '*.hs' \ + -exec ormolu --mode check \ + -o '-XBangPatterns' \ + -o '-XMagicHash' \ + -o '-XTypeApplications' \ + -o '-XPatternSynonyms' \ + {} \+ diff --git a/sh/fmt-nix b/sh/fmt-nix new file mode 100755 index 000000000..6998b75b1 --- /dev/null +++ b/sh/fmt-nix @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Usage: fmt-nix + +set -euo pipefail + +cd "${0%/*}/.." + +echo "Formatting Nix" + +find . -type f -name '*.nix' \ + -exec nixfmt {} \+ diff --git a/sh/fmt-shell b/sh/fmt-shell new file mode 100755 index 000000000..d89128dfd --- /dev/null +++ b/sh/fmt-shell @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Usage: fmt-shell + +set -euo pipefail + +cd "${0%/*}/.." + +echo "Formatting Shell" + +# FIXME: Avoid inplace (-w) modifications for now. +find sh -type f \ + -exec shfmt -s -i 2 -ln bash -l {} \+ \ + -exec shellcheck --shell=bash --format=tty {} \+