make check_assets better
This commit is contained in:
parent
1c617413d5
commit
0edb8bcb6d
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue