#!/bin/bash

# The directory to search
SEARCH_DIR="./mantra-game"

# The file to which all .js files will be appended
OUTPUT_FILE="combined.txt"

# Check if the output file already exists and remove it to start fresh
if [ -f $OUTPUT_FILE ]; then
    rm $OUTPUT_FILE
fi

# Find all .js files and append them to the output file
# Explanation of find options:
# -path './node_modules' -prune : This will skip the node_modules directories
# -o -name '*.js' : This will match all files ending with .js
# -exec cat {} + : For all matched files, concatenate them and append to OUTPUT_FILE
find $SEARCH_DIR -type d -name 'node_modules' -prune -o -type f -name '*.js' -exec cat {} + >> $OUTPUT_FILE

# Print a message indicating success
echo "All .js files have been combined into $OUTPUT_FILE."

