mirror of
https://github.com/kdabir/has.git
synced 2024-11-10 21:26:50 +01:00
✨ add coreutils and archiving utilities to known commands
- [x] command mapping `*coreutils` to `gnu_coreutils` - [x] ✅ add test for gnu_coreutils - [x] 💚 add archiving packages to travis - [x] ✅ add test for archiving commands
This commit is contained in:
parent
0e92f29a24
commit
96c3afe771
@ -142,3 +142,23 @@ teardown() {
|
|||||||
[[ "printf '%b\n' ${lines[0]}" =~ "${checkmark}" ]]
|
[[ "printf '%b\n' ${lines[0]}" =~ "${checkmark}" ]]
|
||||||
[[ "printf '%b\n' ${lines[2]}" =~ '✗' ]]
|
[[ "printf '%b\n' ${lines[2]}" =~ '✗' ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "testing archiving commands" {
|
||||||
|
run $has tar unzip gzip xz unar pv
|
||||||
|
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(echo "${output}" | grep "tar")" ]
|
||||||
|
[ "$(echo "${output}" | grep "unzip")" ]
|
||||||
|
[ "$(echo "${output}" | grep "xz")" ]
|
||||||
|
[ "$(echo "${output}" | grep "unar")" ]
|
||||||
|
[ "$(echo "${output}" | grep "pv")" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "testing coreutils commands" {
|
||||||
|
run $has coreutils sed awk grep sudo file linux-utils
|
||||||
|
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(echo "${lines[0]}" | grep "gnu_coreutils")" ]
|
||||||
|
[ "$(echo "${lines[5]}" | grep "file")" ]
|
||||||
|
[ "$(echo "${lines[6]}" | grep "gnu_coreutils")" ]
|
||||||
|
}
|
||||||
|
@ -5,6 +5,9 @@ addons:
|
|||||||
update: true
|
update: true
|
||||||
packages:
|
packages:
|
||||||
- bc
|
- bc
|
||||||
|
- pv
|
||||||
|
- xz-utils
|
||||||
|
- unar
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
12
has
12
has
@ -81,6 +81,7 @@ __detect(){
|
|||||||
homebrew) command="brew";;
|
homebrew) command="brew";;
|
||||||
awsebcli) command="eb";;
|
awsebcli) command="eb";;
|
||||||
awscli) command="aws";;
|
awscli) command="aws";;
|
||||||
|
*coreutils|linux-utils) command="gnu_coreutils" ;;
|
||||||
*) command=${name} ;;
|
*) command=${name} ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -94,6 +95,10 @@ __detect(){
|
|||||||
vim|emacs|nano|subl) __dynamic_detect--version "${command}" ;;
|
vim|emacs|nano|subl) __dynamic_detect--version "${command}" ;;
|
||||||
bats|tree|ack|autojump) __dynamic_detect--version "${command}" ;;
|
bats|tree|ack|autojump) __dynamic_detect--version "${command}" ;;
|
||||||
jq|ag|brew) __dynamic_detect--version "${command}" ;;
|
jq|ag|brew) __dynamic_detect--version "${command}" ;;
|
||||||
|
apt|apt-get|aptitude) __dynamic_detect--version "${command}" ;;
|
||||||
|
sed|awk|grep|file|sudo) __dynamic_detect--version "${command}" ;;
|
||||||
|
gzip|xz|unar|bzip2) __dynamic_detect--version "${command}" ;;
|
||||||
|
tar|pv) __dynamic_detect--version "${command}" ;;
|
||||||
|
|
||||||
R) __dynamic_detect--version "${command}" ;;
|
R) __dynamic_detect--version "${command}" ;;
|
||||||
node|npm|yarn) __dynamic_detect--version "${command}" ;;
|
node|npm|yarn) __dynamic_detect--version "${command}" ;;
|
||||||
@ -105,6 +110,9 @@ __detect(){
|
|||||||
lein) __dynamic_detect--version "${command}" ;;
|
lein) __dynamic_detect--version "${command}" ;;
|
||||||
aws|eb|sls|gcloud) __dynamic_detect--version "${command}" ;;
|
aws|eb|sls|gcloud) __dynamic_detect--version "${command}" ;;
|
||||||
|
|
||||||
|
# commands that need -v flag
|
||||||
|
unzip) __dynamic_detect-v "${command}" ;;
|
||||||
|
|
||||||
# commands that need -version flag
|
# commands that need -version flag
|
||||||
ant|java|javac) __dynamic_detect-version "${command}" ;;
|
ant|java|javac) __dynamic_detect-version "${command}" ;;
|
||||||
scala|kotlin) __dynamic_detect-version "${command}" ;;
|
scala|kotlin) __dynamic_detect-version "${command}" ;;
|
||||||
@ -142,6 +150,10 @@ __detect(){
|
|||||||
status=$?
|
status=$?
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
## use 'readlink' to test for GNU coreutils
|
||||||
|
# readlink (GNU coreutils) 8.28
|
||||||
|
gnu_coreutils) __dynamic_detect--version readlink ;;
|
||||||
|
|
||||||
has)
|
has)
|
||||||
version=$(has 2>&1 | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1)
|
version=$(has 2>&1 | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1)
|
||||||
status=$?
|
status=$?
|
||||||
|
Loading…
Reference in New Issue
Block a user