Skip to content
Myr

feat: add make fmt for *.sh *.bash

Before adoption: this commit came in with the history the project adopted, so no landing records it.

1. add .editorconfig file, add rules for .sh .bash files. 2. add make fmt target, use: - gofmt *.go. - shfmt *.sh *.bash, shell/completion.bash, shell/key-bindings.bash need a left indent due to an outermost if block. 3. add shfmt check for bash scripts in make lint target. 4. install shfmt in actions.

authored by xieyonn · committed by Junegunn Choi · parent 148b0a9 · Browse files · 4 files+44 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+44 added−4 removed

  • other:+44 added−4 removed

4 files+44 added−4 removed

modified:.github/workflows/linux.yml+1 added-1 removed
modified:.github/workflows/macos.yml+1 added-1 removed
added:.editorconfig+20 added
1root = true23[*.{sh,bash}]4indent_style = space5indent_size = 26simplify = true7binary_next_line = true8switch_case_indent = true9space_redirects = true10function_next_line = false1112# also bash scripts.13[{install,uninstall,bin/fzf-preview.sh,bin/fzf-tmux}]14indent_style = space15indent_size = 216simplify = true17binary_next_line = true18switch_case_indent = true19space_redirects = true20function_next_line = false
modified:Makefile+22 added-2 removed
3 unmodified lines
4MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))5ROOT_DIR := $(shell dirname $(MAKEFILE))6SOURCES := $(wildcard *.go src/*.go src/*/*.go shell/*sh man/man1/*.1) $(MAKEFILE)78BASH_SCRIPTS := $(ROOT_DIR)/bin/fzf-preview.sh \9 $(ROOT_DIR)/bin/fzf-tmux \10 $(ROOT_DIR)/install \11 $(ROOT_DIR)/uninstall \12 $(ROOT_DIR)/shell/common.sh \13 $(ROOT_DIR)/shell/update-common.sh14BASH_SCRIPTS_INDENT_LEFT := $(ROOT_DIR)/shell/completion.bash \15 $(ROOT_DIR)/shell/key-bindings.bash1617ifdef FZF_VERSION18VERSION := $(FZF_VERSION)19else20VERSION := $(shell git describe --abbrev=0 2> /dev/null | sed "s/^v//")
75 unmodified lines
9697bench:98 cd src && SHELL=/bin/sh GOOS= $(GO) test -v -tags "$(TAGS)" -run=Bench -bench=. -benchmem9991lint: $(SOURCES) test/*.rb test/lib/*.rb100lint: $(SOURCES) test/*.rb test/lib/*.rb ${BASH_SCRIPTS}101 [ -z "$$(gofmt -s -d src)" ] || (gofmt -s -d src; exit 1)102 bundle exec rubocop -a --require rubocop-minitest --require rubocop-performance103 [ -z "$$(shfmt -d $(BASH_SCRIPTS))" ] || (echo "format bash files by (make fmt)"; exit 1)104105fmt: $(SOURCES) $(BASH_SCRIPTS) $(BASH_SCRIPTS_INDENT_LEFT)106 gofmt -s -w src107 shfmt -w $(BASH_SCRIPTS)108 # shift left because we have an outermost if block for historical reasons.109 for f in $(BASH_SCRIPTS_INDENT_LEFT); do \110 shfmt -w "$$f"; \111 tmp=$$(mktemp); \112 sed 's/^ //' "$$f" > "$$tmp" && mv "$$tmp" "$$f"; \113 done114115install: bin/fzf116117generate:118 PATH=$(PATH):$(GOPATH)/bin $(GO) generate ./...
89 unmodified lines
208update:209 $(GO) get -u210 $(GO) mod tidy211192.PHONY: all generate build release test itest bench lint install clean docker docker-test update212.PHONY: all generate build release test itest bench lint install clean docker docker-test update fmt