From ceee7e85f9892e2cd47a6954727f2d9ef8aeb423 Mon Sep 17 00:00:00 2001 From: raspbeguy Date: Wed, 13 May 2020 14:46:06 +0200 Subject: [PATCH] bad commit --- test/check_assets.sh | 29 +++++++++++++++++++++++++ test/config.sh | 2 ++ rename_posts.sh => test/rename_posts.sh | 10 ++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/check_assets.sh create mode 100644 test/config.sh rename rename_posts.sh => test/rename_posts.sh (64%) diff --git a/test/check_assets.sh b/test/check_assets.sh new file mode 100644 index 0000000..e19ede6 --- /dev/null +++ b/test/check_assets.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +if [ -f config.sh ]; then + . config.sh +fi + +if [ -z "$POSTS_DIR" ] +then + echo "POSTS_DIR environment variable is unset." > /dev/stderr + exit 2 +fi + +if [ -z "$ASSETS_DIR" ] +then + echo "ASSETS_DIR environment variable is unset." > /dev/stderr + 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 + +exit $rc diff --git a/test/config.sh b/test/config.sh new file mode 100644 index 0000000..db70187 --- /dev/null +++ b/test/config.sh @@ -0,0 +1,2 @@ +POSTS_DIR="../content/posts" +ASSETS_DIR="../assets" diff --git a/rename_posts.sh b/test/rename_posts.sh similarity index 64% rename from rename_posts.sh rename to test/rename_posts.sh index 9f5b660..f3fd88a 100755 --- a/rename_posts.sh +++ b/test/rename_posts.sh @@ -1,6 +1,14 @@ #!/bin/bash -POSTS_DIR="content/posts" +if [ -f config.sh ]; then + . config.sh +fi + +if [ -z "$POSTS_DIR" ] +then + echo "POSTS_DIR environment variable is unset." > /dev/stderr + exit 2 +fi cd $POSTS_DIR for post in *