Skip to content

Commit

Permalink
show warning and ask user confirmation before copying files
Browse files Browse the repository at this point in the history
  • Loading branch information
tang-mm committed Jul 31, 2024
1 parent f0270a3 commit a5f6382
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,27 @@ fi
# Check if .gitignore exists in the destination directory
# If exists, append the contents of the source .gitignore to the destination .gitignore
if [ -f "$install_directory/.gitignore" ]; then
cat "$temp_directory/sp-files/.gitignore" >> "$install_directory/.gitignore"
echo "ACTION REQUIRED: .gitignore already exists in the destination directory. Check the contents before saving the file!"
read -p "Do you want to append the list of ignored files for Sphinx docs to the existing .gitginore? Enter 'n' to skip. (y/n): " confirm
if [ "$confirm" = "y" ]; then
echo "Appending contents to the existing .gitignore..."
cat "$temp_directory/sp-files/.gitignore" >> "$install_directory/.gitignore"
else
echo "Operation skipped by the user. No .gitignore rule is created for Sphinx docs."
rm "$temp_directory/sp-files/.gitignore"
fi

# Check if Makefile exists in the destination directory
# If exists, append the contents of the source Makefile to the destination Makefile
if [ -f "$install_directory/Makefile" ]; then
cat "$temp_directory/sp-files/Makefile" >> "$install_directory/Makefile"
echo "ACTION REQUIRED: Makefile already exists in the destination directory. Check the contents before running the targets!"
read -p "Do you want to create the Sphinx docs Makefile as a backup file? Enter 'n' to skip. (y/n): " confirm
if [ "$confirm" = "y" ]; then
# Create a copy of Sphinx docs Makefile as backup
backup_makefile="$install_directory/Makefile.backup.$(date +%Y%m%d%H%M%S)"
echo "Creating a backup Makefile for Sphinx docs: $backup_makefile"
cp "$temp_directory/sp-files/Makefile" "$backup_makefile"
else
echo "Operation skipped by the user. No Makefile is created for Sphinx docs."
rm "$temp_directory/sp-files/Makefile"
fi

Expand Down

0 comments on commit a5f6382

Please sign in to comment.