2
1
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:
Kunal Dabir 2015-02-13 13:20:25 +05:30
parent 7eccca0a44
commit ebe59833f3
16 changed files with 30 additions and 28 deletions

View File

@ -10,6 +10,8 @@ if [[ "$1" == "--no-version" ]]; then
NO_VERSION=0
fi
SIMPLE_VERSIONING="([[:digit:]]+\.?){2,3}"
if [[ $TERM == xterm-*color ]]; then
PASS="\E[32m$PASS\E[0m"
FAIL="\E[31m$FAIL\E[0m"
@ -23,7 +25,7 @@ _dq_report () {
if [ "$NO_VERSION" -eq 0 ]; then
printf "$PASS $1\n"
else
printf "$PASS %-30s %s\n" $1 $3
printf "$PASS %-30s %s \n" "${1}" "${3}"
fi
OK=$(($OK+1))
else

View File

@ -1,6 +1,6 @@
command_name="git"
output=$(git --version)
output=$(git --version 2>&1)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
_dq_report "$command_name" $status "$version"

View File

@ -1,5 +1,5 @@
output=$(java -version 2>&1)
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"

View File

@ -1,6 +1,6 @@
command_name="node"
output=$(node --version)
output=$(node --version 2>&1)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
_dq_report "$command_name" $status "$version"

View File

@ -1,5 +1,5 @@
output=$(python --version 2>&1)
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"

View File

@ -1,5 +1,5 @@
output=$(ruby --version 2>&1)
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"

View File

@ -1,6 +1,6 @@
command_name="mongo-client"
output=$(mongo --version)
output=$(mongo --version 2>&1)
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"

View File

@ -1,6 +1,6 @@
command_name="mongodb"
output=$(mongod --version)
output=$(mongod --version 2>&1)
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"

View File

@ -1,6 +1,6 @@
command_name="bower"
output=$(bower --version)
output=$(bower --version 2>&1)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
_dq_report "$command_name" $status "$version"

View File

@ -1,6 +1,6 @@
command_name="coffee"
output=$(coffee --version)
output=$(coffee --version 2>&1)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
_dq_report "$command_name" $status "$version"

View File

@ -1,6 +1,6 @@
command_name="grunt"
output=$(grunt --version)
output=$(grunt --version 2>&1)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
_dq_report "$command_name" $status "$version"

View File

@ -1,6 +1,6 @@
command_name="npm"
output=$(npm --version)
output=$(npm --version 2>&1)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
_dq_report "$command_name" $status "$version"

View File

@ -1,6 +1,6 @@
command_name="sass"
output=$(sass --version)
output=$(sass --version 2>&1)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
_dq_report "$command_name" $status "$version"

View File

@ -1,6 +1,6 @@
command_name="yeoman"
output=$(yo --version)
output=$(yo --version 2>&1)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
version=$(echo "$output" | egrep -o "$SIMPLE_VERSIONING")
_dq_report "$command_name" $status "$version"

View File

@ -1,5 +1,5 @@
output=$(groovy --version)
output=$(groovy --version 2>&1)
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"

View File

@ -1,6 +1,6 @@
command_name="gradle"
output=$(gradle -v 2>&1)
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"