proustibat/fbrgsmn.mobile.app

View on GitHub
sonar.sh

Summary

Maintainability
Test Coverage
#!/bin/bash

echo -e "#####################################################"
echo -e " START SONAR SCRIPT"
echo -e "#####################################################"

function readJson {
  UNAMESTR=`uname`
  if [[ "$UNAMESTR" == 'Linux' ]]; then
    SED_EXTENDED='-r'
  elif [[ "$UNAMESTR" == 'Darwin' ]]; then
    SED_EXTENDED='-E'
  fi;

  VALUE=`grep -m 1 "\"${2}\"" ${1} | sed ${SED_EXTENDED} 's/^ *//;s/.*: *"//;s/",?//'`

  if [ ! "$VALUE" ]; then
    echo "Error: Cannot find \"${2}\" in ${1}" >&2;
    exit 1;
  else
    echo $VALUE ;
  fi;
}

VERSION=`readJson package.json version` || exit 1;

sonar-scanner -X -Dsonar.projectVersion=$VERSION