Skip to content

Commit ad4cfce

Browse files
committed
Add checks to tasks for shell tools` being installed
The preferred approach is for the tasks to install their specific dependencies as needed, in a manner that does not pollute the task user's environment. However, it doesn't appear to be feasible to do this with the shfmt and ShellCheck tools used by the `shell:format` task, so the task user is responsible for installing this tool. In the event the task user does not have such a tool installed (or installation not in PATH), the task should provide a helpful error message, which is provided by this change.
1 parent e17c797 commit ad4cfce

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Taskfile.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,11 @@ tasks:
269269
shell:lint:
270270
desc: Lint shell scripts
271271
cmds:
272-
# https://github.com/koalaman/shellcheck
272+
- |
273+
if ! which shellcheck &>/dev/null; then
274+
echo "shellcheck not installed or not in PATH. Please install: https://github.com/koalaman/shellcheck#installing"
275+
exit 1
276+
fi
273277
- |
274278
shopt -s globstar # Needed to check all scripts recursively.
275279
shellcheck ./**/*.sh
@@ -283,6 +287,11 @@ tasks:
283287
shell:format:
284288
desc: Format shell scripts
285289
cmds:
290+
- |
291+
if ! which shfmt &>/dev/null; then
292+
echo "shfmt not installed or not in PATH. Please install: https://github.com/mvdan/sh#shfmt"
293+
exit 1
294+
fi
286295
- shfmt -l -w .
287296

288297
config:check:

0 commit comments

Comments
 (0)