mirror of
https://github.com/kdabir/has.git
synced 2024-11-10 21:26:50 +01:00
extracting regex for version matching in setup. bit ugly, but can be refactored later. also grep was acting different on mac/linux mac/BSD grep no longer has -P so finally using egrep. character class \d was not working on some linux so used :digit:
This commit is contained in:
parent
7eccca0a44
commit
ebe59833f3
@ -10,6 +10,8 @@ if [[ "$1" == "--no-version" ]]; then
|
|||||||
NO_VERSION=0
|
NO_VERSION=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
SIMPLE_VERSIONING="([[:digit:]]+\.?){2,3}"
|
||||||
|
|
||||||
if [[ $TERM == xterm-*color ]]; then
|
if [[ $TERM == xterm-*color ]]; then
|
||||||
PASS="\E[32m$PASS\E[0m"
|
PASS="\E[32m$PASS\E[0m"
|
||||||
FAIL="\E[31m$FAIL\E[0m"
|
FAIL="\E[31m$FAIL\E[0m"
|
||||||
@ -23,7 +25,7 @@ _dq_report () {
|
|||||||
if [ "$NO_VERSION" -eq 0 ]; then
|
if [ "$NO_VERSION" -eq 0 ]; then
|
||||||
printf "$PASS $1\n"
|
printf "$PASS $1\n"
|
||||||
else
|
else
|
||||||
printf "$PASS %-30s %s\n" $1 $3
|
printf "$PASS %-30s %s \n" "${1}" "${3}"
|
||||||
fi
|
fi
|
||||||
OK=$(($OK+1))
|
OK=$(($OK+1))
|
||||||
else
|
else
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
command_name="git"
|
command_name="git"
|
||||||
output=$(git --version)
|
output=$(git --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
|
||||||
|
|
||||||
_dq_report "$command_name" $status "$version"
|
_dq_report "$command_name" $status "$version"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
output=$(java -version 2>&1)
|
output=$(java -version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*\.\d*" | head -1)
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING" | head -1)
|
||||||
|
|
||||||
_dq_report 'java' $status "$version"
|
_dq_report 'java' $status "$version"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
command_name="node"
|
command_name="node"
|
||||||
output=$(node --version)
|
output=$(node --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
|
||||||
|
|
||||||
_dq_report "$command_name" $status "$version"
|
_dq_report "$command_name" $status "$version"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
output=$(python --version 2>&1)
|
output=$(python --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*\.\d*" | head -1)
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING" | head -1)
|
||||||
|
|
||||||
_dq_report 'python' $status "$version"
|
_dq_report 'python' $status "$version"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
output=$(ruby --version 2>&1)
|
output=$(ruby --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*\.\d*" | head -1)
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING" | head -1)
|
||||||
|
|
||||||
_dq_report 'ruby' $status "$version"
|
_dq_report 'ruby' $status "$version"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
command_name="mongo-client"
|
command_name="mongo-client"
|
||||||
output=$(mongo --version)
|
output=$(mongo --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*.\d*" | head -1)
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING" | head -1)
|
||||||
|
|
||||||
_dq_report "$command_name" $status "$version"
|
_dq_report "$command_name" $status "$version"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
command_name="mongodb"
|
command_name="mongodb"
|
||||||
output=$(mongod --version)
|
output=$(mongod --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*.\d*" | head -1)
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING" | head -1)
|
||||||
|
|
||||||
_dq_report "$command_name" $status "$version"
|
_dq_report "$command_name" $status "$version"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
command_name="bower"
|
command_name="bower"
|
||||||
output=$(bower --version)
|
output=$(bower --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
|
||||||
|
|
||||||
_dq_report "$command_name" $status "$version"
|
_dq_report "$command_name" $status "$version"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
command_name="coffee"
|
command_name="coffee"
|
||||||
output=$(coffee --version)
|
output=$(coffee --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
|
||||||
|
|
||||||
_dq_report "$command_name" $status "$version"
|
_dq_report "$command_name" $status "$version"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
command_name="grunt"
|
command_name="grunt"
|
||||||
output=$(grunt --version)
|
output=$(grunt --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
|
||||||
|
|
||||||
_dq_report "$command_name" $status "$version"
|
_dq_report "$command_name" $status "$version"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
command_name="npm"
|
command_name="npm"
|
||||||
output=$(npm --version)
|
output=$(npm --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
|
||||||
|
|
||||||
_dq_report "$command_name" $status "$version"
|
_dq_report "$command_name" $status "$version"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
command_name="sass"
|
command_name="sass"
|
||||||
output=$(sass --version)
|
output=$(sass --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
|
||||||
|
|
||||||
_dq_report "$command_name" $status "$version"
|
_dq_report "$command_name" $status "$version"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
command_name="yeoman"
|
command_name="yeoman"
|
||||||
output=$(yo --version)
|
output=$(yo --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
|
||||||
|
|
||||||
_dq_report "$command_name" $status "$version"
|
_dq_report "$command_name" $status "$version"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
output=$(groovy --version)
|
output=$(groovy --version 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*\.\d*" | head -1)
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING" | head -1)
|
||||||
|
|
||||||
_dq_report 'groovy' $status "$version"
|
_dq_report 'groovy' $status "$version"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
command_name="gradle"
|
command_name="gradle"
|
||||||
output=$(gradle -v 2>&1)
|
output=$(gradle -v 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
version=$(echo "$output" | grep -o "\d*\.\d*" | head -1)
|
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING" | head -1)
|
||||||
|
|
||||||
_dq_report "$command_name" $status "$version"
|
_dq_report "$command_name" $status "$version"
|
Loading…
Reference in New Issue
Block a user