From d1d6adc81acf290dc8e2f4caa34bdc2a4cb8186e Mon Sep 17 00:00:00 2001 From: Martin Berg Alstad <600878@stud.hvl.no> Date: Sat, 24 Dec 2022 11:33:41 +0100 Subject: [PATCH] Reformated script to use function --- build_extra.sh | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/build_extra.sh b/build_extra.sh index 6e8176f..b24c08c 100644 --- a/build_extra.sh +++ b/build_extra.sh @@ -5,24 +5,17 @@ if [ ! -e dist ]; then vite build fi -if [ -e robots.txt ]; then - cp robots.txt dist -else - echo "robots.txt not found" -fi +# Copying the file ($1) to the dist directory, or to subdirectory ($2) +copy() { + if [ -e "$1" ]; then + cp "$1" dist/"$2" + else + echo "'$1' not found, skipping" + fi +} mkdir -p "dist/.well-known" -if [ -e "dist/.well-known" ]; then - if [ -e security.txt ]; then - cp security.txt dist/.well-known - else - echo "security.txt not found" - fi -fi - -if [ -e .htaccess ]; then - cp .htaccess dist -else - echo ".htaccess not found" -fi +copy robots.txt +copy security.txt .well-known +copy .htaccess