mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-27 16:59:21 +00:00
52 lines
1.3 KiB
Bash
Executable file
52 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/sh
|
|
|
|
# ====================================================================
|
|
# Tool to check the syntax of `.qml` files.
|
|
# ====================================================================
|
|
|
|
RESOURCES_FILE="resources.qrc"
|
|
LINTER=qmllint-qt5
|
|
|
|
RED='\e[1;31m'
|
|
GREEN='\e[1;32m'
|
|
BLUE='\e[1;34m'
|
|
NC='\e[0m'
|
|
|
|
function go_to_source_file_dir {
|
|
# See: http://stackoverflow.com/questions/59895/can-a-bash-script-tell-which-directory-it-is-stored-in
|
|
SOURCE="${BASH_SOURCE[0]}"
|
|
while [ -h "$SOURCE" ]; do
|
|
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
|
SOURCE="$(readlink "$SOURCE")"
|
|
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
done
|
|
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
|
|
|
cd $SCRIPT_DIR/..
|
|
}
|
|
|
|
go_to_source_file_dir
|
|
|
|
printf "${BLUE}Checking qml files...${NC}\n"
|
|
|
|
so_far_so_good=0
|
|
while read line
|
|
do
|
|
result=$(
|
|
printf "$line" |
|
|
sed -n 's/^\s*<\s*file\s*>\s*\(.*\.qml\)\s*<\s*\/file\s*>\s*$/\1/p'
|
|
)
|
|
|
|
if [[ ! -z $result ]] && ! $LINTER "$result"; then
|
|
so_far_so_good=1
|
|
fi
|
|
done < $RESOURCES_FILE
|
|
|
|
if [[ $so_far_so_good == 0 ]]; then
|
|
printf "${GREEN}Done. No qml error found.\n"
|
|
else
|
|
printf "${RED}One or more errors were found.\n"
|
|
fi
|
|
printf "${NC}"
|
|
|
|
exit $so_far_so_good
|