From 3914df391f39bd55b3c34f9be1844a9d61aa265f Mon Sep 17 00:00:00 2001 From: fiftydinar <65243233+fiftydinar@users.noreply.github.com> Date: Sat, 3 Feb 2024 19:40:24 +0100 Subject: [PATCH] fix(files): Ensure that parent dot files & folders are copied (#115) * fix(files): Fix build error on copying dotfiles Enable dotglob when copying folders/files, disable when it's finished. * chore(files): Ensure that dotglob is executed outside of loop * fix(files): Ensure that .gitkeep file is not present in the build image * fix(files): Ensure that cp command ignores if something is present in directory or not --- modules/files/files.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/files/files.sh b/modules/files/files.sh index 51ff107..6bfbd91 100644 --- a/modules/files/files.sh +++ b/modules/files/files.sh @@ -6,6 +6,7 @@ set -euo pipefail get_yaml_array FILES '.files[]' "$1" cd "$CONFIG_DIRECTORY/files" +shopt -s dotglob if [[ ${#FILES[@]} -gt 0 ]]; then echo "Adding files to image" @@ -17,17 +18,21 @@ if [[ ${#FILES[@]} -gt 0 ]]; then mkdir -p "$DEST" fi echo "Copying $FILE to $DEST" - cp -r "$FILE"/* $DEST + cp -rf "$FILE"/* $DEST + rm -f "$DEST"/.gitkeep elif [ -f "$FILE" ]; then DEST_DIR=$(dirname "$DEST") if [ ! -d "$DEST_DIR" ]; then mkdir -p "$DEST_DIR" fi echo "Copying $FILE to $DEST" - cp $FILE $DEST + cp -f $FILE $DEST + rm -f "$DEST"/.gitkeep else echo "File or Directory $FILE Does Not Exist in $CONFIG_DIRECTORY/files" exit 1 fi done fi + +shopt -u dotglob