@@ -40,7 +40,7 @@ set -euo pipefail
4040# - .specify/scripts/bash
4141# - .specify/templates
4242# - adr-template.md
43- # - docs/codebase-overview/ (with .gitignore )
43+ # - docs/codebase-overview/ (with .gitkeep )
4444# - docs/prompt-reports/ (with .gitignore)
4545# - project.code-workspace (if not already present)
4646#
@@ -522,6 +522,7 @@ function copy-adr-template() {
522522}
523523
524524# Copy docs/codebase-overview directory to the destination.
525+ # Only copies .gitkeep if the destination directory is empty or doesn't exist.
525526# Arguments (provided as function parameters):
526527# $1=[destination directory path]
527528function copy-docs-codebase-overview() {
@@ -530,7 +531,18 @@ function copy-docs-codebase-overview() {
530531 mkdir -p " ${dest} "
531532
532533 print-info " Copying docs/codebase-overview to ${dest} "
533- cp -R " ${DOCS_CODEBASE_OVERVIEW} /." " ${dest} /"
534+
535+ # Check if destination directory has any files (excluding hidden files that start with .)
536+ local file_count
537+ file_count=$( find " ${dest} " -maxdepth 1 -type f ! -name " .*" 2> /dev/null | wc -l | tr -d ' ' )
538+
539+ if [[ " ${file_count} " -eq 0 ]]; then
540+ # Directory is empty, copy everything including .gitkeep
541+ cp -R " ${DOCS_CODEBASE_OVERVIEW} /." " ${dest} /"
542+ else
543+ # Directory has files, copy everything except .gitkeep
544+ find " ${DOCS_CODEBASE_OVERVIEW} " -maxdepth 1 -type f ! -name " .gitkeep" -exec cp {} " ${dest} /" \; 2> /dev/null || true
545+ fi
534546}
535547
536548# Copy docs/prompt-reports directory to the destination.
0 commit comments