File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change 22
33# Defined scripts.
44function lint() {
5+ _check_binaries " shellcheck"
56 shellcheck --format=tty --shell=sh ./** /* .sh
67}
78
89function test() {
9- find . -name " *.bats" -exec sh -c " bats {}" " ;"
10+ _check_binaries " bats"
11+ find . -iname " *.bats" -exec sh -c " bats {}" " ;"
1012}
1113
1214function format() {
13- find . -name " *.sh" -exec sh -c " shfmt -bn -ci -w {}" " ;"
15+ _check_binaries " shfmt"
16+ find . -iname " *.sh" -exec sh -c " shfmt -bn -ci -w {}" " ;"
17+ }
18+
19+ function watch() {
20+ _check_binaries " entr"
21+ find . -type f -iname " *.sh" -o -iname " *.bats" | entr -c bash run check
1422}
1523
1624function check() {
@@ -22,13 +30,13 @@ function check() {
2230set -e
2331
2432# Check binaries.
25- [ -x " $( command -v shellcheck ) " ] || {
26- echo " shellcheck is required " >&2
27- exit 1
28- }
29- [ -x " $( command -v bats ) " ] || {
30- echo " bats is required " >&2
31- exit 1
33+ function _check_binaries() {
34+ for i in " $@ " ; do
35+ [ -x " $( command -v " $i " ) " ] || {
36+ echo " bats is required " >&2
37+ exit 1
38+ }
39+ done
3240}
3341
3442# Check for scripts.
You can’t perform that action at this time.
0 commit comments