Add shfmt (#90)

* feat: add shfmt

Add support for shfmt

* Handle multiple architectures

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
This commit is contained in:
Ellis Kenyő 2022-05-12 20:52:57 +01:00 committed by GitHub
parent 982df5a2e0
commit b5dbab53ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 1 deletions

View file

@ -933,6 +933,7 @@ being run, for diagnostic purposes."
"--enable-outside-detected-project"))
(phpcs . ("apheleia-phpcs"))
(prettier . (npx "prettier" "--stdin-filepath" filepath))
(shfmt . ("shfmt"))
(rustfmt . ("rustfmt" "--quiet" "--emit" "stdout"))
(terraform . ("terraform" "fmt" "-")))
"Alist of code formatting commands.
@ -1065,6 +1066,7 @@ function: %s" command)))
(rustic-mode . rustfmt)
(rust-mode . rustfmt)
(sass-mode . prettier)
(sh-mode . shfmt)
(terraform-mode . terraform)
(TeX-latex-mode . latexindent)
(TeX-mode . latexindent)

View file

@ -4,7 +4,7 @@ set -euxo pipefail
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y curl gnupg lsb-release
apt-get install -y ca-certificates curl gnupg lsb-release
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -

View file

@ -0,0 +1,21 @@
ver="$(latest_release mvdan/sh)"
arch="$(uname -m)"
case "${arch}" in
"x86_64")
arch="amd64"
;;
"i386")
arch="386"
;;
"aarch64")
arch="arm64"
;;
*)
echo >&2 "unsupported architecture: ${arch}"
exit 1
;;
esac
wget "https://github.com/mvdan/sh/releases/download/${ver}/shfmt_${ver}_linux_${arch}" -O /usr/local/bin/shfmt
chmod +x /usr/local/bin/shfmt

View file

@ -0,0 +1,2 @@
function f(){
thing;}

View file

@ -0,0 +1,3 @@
function f() {
thing
}