Skip to content

Instantly share code, notes, and snippets.

@Potherca
Last active October 8, 2020 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Potherca/e473a28d15c0d4d4db1468befa6c574a to your computer and use it in GitHub Desktop.
Save Potherca/e473a28d15c0d4d4db1468befa6c574a to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
ds() {
is_command() {
[[ -x "$("${command}" -v "$1" 2> /dev/null)" ]] && return 0
return 1
}
is_command 'dos2unix' || { echo 'dos2unix is required'; exit 1; }
exit 0;
}
#!/usr/bin/env bats
source "${BATS_TEST_DIRNAME}/ds.sh"
@test 'dos2unix does not exist' {
hash -r
BASH_CMDS['dos2unix']='/no/such/dir/dos2unix'
run ds
[ "${status}" -eq 1 ]
[ "${output}" = 'dos2unix is required' ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment