From 618beb711035a8438285cf0a3bbe8b9b4b233320 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 9 Jan 2018 10:15:08 -0800 Subject: [PATCH] test-documentation: Factor out the terminal goo for coloring messages. --- tools/test-documentation | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/test-documentation b/tools/test-documentation index ea2871001e..f9e676093c 100755 --- a/tools/test-documentation +++ b/tools/test-documentation @@ -1,6 +1,10 @@ #!/usr/bin/env bash set -e +color_message () { + local color_code="$1" message="$2" + echo -e "\e[${color_code}m${message}\e[0m" +} case $1 in -h|--help) @@ -22,22 +26,16 @@ rm -rf _build # The crawler would take a very long time to finish and TravisCI would fail as a result. sphinx-build -j8 -b html -d _build/doctrees -D html_theme_options.collapse_navigation=True . _build/html -echo -en "\033[0;94m" -echo "Testing links in documentation..." -echo -en "\033[0m" +color_message 94 "Testing links in documentation..." cd ../tools/documentation_crawler set +e scrapy crawl_with_status documentation_crawler $loglevel result=$? if [ "$result" = 1 ]; then - echo -en "\033[0;91m" - echo "Failed!" - echo -en "\033[0m" + color_message 91 "Failed!" exit 1 else - echo -en "\033[0;92m" - echo "Passed!" - echo -en "\033[0m" + color_message 92 "Passed!" exit 0 fi