@@ -86,7 +86,7 @@ FILES_ADDED=()
8686FILES_WITH_CHANGES=()
8787
8888# Loop through all files in the template directory
89- while IFS= read -r -d ' ' file; do
89+ while IFS= read -r -d ' ' file || [[ -n $file ]] ; do
9090 relative_path=" ${file# ./ } " # Remove leading './'
9191
9292 # Check if the file is ignored
@@ -110,9 +110,13 @@ while IFS= read -r -d '' file; do
110110 if ! diff -q " $file " " $target_path " > /dev/null 2>&1 ; then
111111 if is_merge " $relative_path " ; then
112112 echo " Merging changes from $relative_path "
113- echo node " $( dirname " $0 " ) /merge.js" " $target_path " " $file "
114- node " ${scriptdir} /merge.js" " $target_path " " $file " > " $target_path .merged"
115- mv " $target_path .merged" " $target_path "
113+ cp " $target_path " " ${target_path} .bak"
114+ node " ${scriptdir} /merge.js" " $target_path " " $file " > " ${target_path} .merged"
115+ if ! cmp -s " ${target_path} .merged" " ${target_path} .bak" ; then
116+ FILES_WITH_CHANGES+=(" ${relative_path} " )
117+ mv " ${target_path} .merged" " $target_path "
118+ fi
119+ rm -f " ${target_path} .merged" " ${target_path} .bak"
116120 else
117121 echo " Copying changes from $relative_path "
118122 cp " $file " " $target_path "
@@ -123,19 +127,19 @@ while IFS= read -r -d '' file; do
123127 fi
124128done < <( find . -type f -print0)
125129
126- echo " ${# FILES_ADDED[@]} " files added, " ${# FILES_WITH_CHANGES[@]} " files with changes detected.
127-
128130echo ------------------------------------------
131+ echo " ${# FILES_ADDED[@]} files added, ${# FILES_WITH_CHANGES[@]} files with changes detected."
129132
130- if [ " $changes_only " == false ]; then
133+ if [[ " $changes_only " == false && ${ # FILES_ADDED[@]} -gt 0 ] ]; then
131134 echo ------------------------------------------
132135 echo " New files added:"
133136 printf ' - %s\n' " ${FILES_ADDED[@]} "
134137fi
135138
136-
137- if [ " $new_only " == false ]; then
139+ if [[ " $new_only " == false && ${# FILES_WITH_CHANGES[@]} -gt 0 ]]; then
138140 echo ------------------------------------------
139141 echo " Changed files:"
140142 printf ' - %s\n' " ${FILES_WITH_CHANGES[@]} "
141143fi
144+
145+ echo ------------------------------------------
0 commit comments