git

My personal website source code
Log | Files | Refs | Submodules | README | LICENSE

commit b9c04eb5b947724a795cf933a19b226cd28cad4b
parent 6fc677dd43374fa31b33d5e2e1e647305f05f8a6
Author: Luís Ferreira <[email protected]>
Date:   Tue, 10 Aug 2021 03:34:38 +0100

scripts: make postscript to ignore files

Signed-off-by: Luís Ferreira <[email protected]>

Diffstat:
A.gohugoignore | 2++
MMakefile | 5++++-
Ascripts/ignore-files.sh | 36++++++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/.gohugoignore b/.gohugoignore @@ -0,0 +1,2 @@ +^/generate\.sh$ +^/content/ diff --git a/Makefile b/Makefile @@ -1,4 +1,4 @@ -build: build-static build-hugo +build: build-static build-hugo postscript-build serve: build-static serve-hugo build-static: @@ -8,6 +8,9 @@ build-static: build-hugo: hugo +postscript-build: + ./scripts/ignore-files.sh + serve-hugo: hugo server diff --git a/scripts/ignore-files.sh b/scripts/ignore-files.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +ignore_file=".gohugoignore" +project_folder="public" + +if [[ $# == 1 ]]; then + project_folder="$1" +elif [[ $# == 2 ]]; then + ignore_file="$1" + project_folder="$2" +elif [[ $# != 0 ]]; then + cat <<EOF +Usage: + ignore-files.sh + ignore-files.sh <ignore file> <publish-folder> + ignore-files.sh <publish-folder> +EOF +fi + +if [ ! -f "$ignore_file" ]; then + echo "Ignore file $ignore_file not found." + exit 1 +fi + +if [ ! -d "$project_folder" ]; then + echo "Project folder $project_folder not found." + exit 1 +fi + +while IFS= read -r -d $'\n' ientry; do + while IFS= read -r -d $'\n' fentry; do + echo "Ignoring $fentry..." + rm -rf "$fentry" + done < <(find "$project_folder" | sed "s|^$project_folder||" | grep "$ientry" | sed -e "s|^|$project_folder|") +done < <(cat "$ignore_file") +