From 0edb8bcb6d61fa82e6d7b81621ab66cf4199abab Mon Sep 17 00:00:00 2001 From: raspbeguy Date: Wed, 13 May 2020 16:51:09 +0200 Subject: [PATCH] make check_assets better --- tests/check_assets.sh | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) mode change 100644 => 100755 tests/check_assets.sh diff --git a/tests/check_assets.sh b/tests/check_assets.sh old mode 100644 new mode 100755 index e19ede6..781d019 --- a/tests/check_assets.sh +++ b/tests/check_assets.sh @@ -1,7 +1,9 @@ #!/bin/bash -if [ -f config.sh ]; then - . config.sh +BASEDIR=`dirname $0` + +if [ -f $BASEDIR/config.sh ]; then + . $BASEDIR/config.sh fi if [ -z "$POSTS_DIR" ] @@ -16,14 +18,33 @@ then exit 2 fi -rc=0 -sed -rn 's|^.*\!\[.*\]\(%assets_url%/(.*)\)$|\1|p' $POSTS_DIR/* | while read line -do - if [ ! -f "$ASSETS_DIR/$line" ] - then - echo "$line not found" - rc=1 - fi -done +function check(){ + local rc=0 + sed -rn 's|^.*\!\[.*\]\(%assets_url%/(.*)\)$|\1|p' $1 | while read line + do + if [ ! -f "$BASEDIR/$ASSETS_DIR/$line" ] + then + echo "`basename $1`: $line not found" >&2 + rc=1 + fi + done + return $rc +} + +if [ -z "$1" ] +then + rc=0 + for file in $BASEDIR/$POSTS_DIR/* + do + check $file + if [ $? -ne 0 ] + then + rc=1 + fi + done +else + check $BASEDIR/$POSTS_DIR/$1 + rc=$? +fi exit $rc