diff --git a/FIRST_INSTALL b/FIRST_INSTALL old mode 100755 new mode 100644 diff --git a/composer.json b/composer.json index 99441bd..950658f 100755 --- a/composer.json +++ b/composer.json @@ -65,7 +65,8 @@ "bash devtools/push.bash", "git push origin develop", "composer run tests", - "composer run lint" + "composer run lint", + "bash devtools/count_php_lines.bash" ], "pull": [ "export COMPOSER_ALLOW_SUPERUSER=1", diff --git a/devtools/count_php_lines.bash b/devtools/count_php_lines.bash new file mode 100755 index 0000000..0d26394 --- /dev/null +++ b/devtools/count_php_lines.bash @@ -0,0 +1,36 @@ +#!/bin/bash + +# Set the directory to search for PHP files +directory="./" + +# Initialize the line count +line_count=0 + +apt install bc -y >> /dev/null 2>&1 + +# Function to recursively count lines of code in PHP files +count_lines() { + local dir="$1" + local files=$(find "$dir" -type f -name "*.php" ! -path "*/node_modules/*" ! -path "*/vendor/*") + + for file in $files; do + # Count the lines of code in the file and add it to the line count + lines=$(wc -l < "$file") + line_count=$((line_count + lines)) + done +} + +# Call the function to count lines of code +count_lines "$directory" + +# Format the line count +if (( line_count >= 1000000 )); then + formatted_count=$(printf "%.2fM" "$(bc -l <<< "$line_count/1000000")") +elif (( line_count >= 1000 )); then + formatted_count=$(printf "%.2fK" "$(bc -l <<< "$line_count/1000")") +else + formatted_count=$line_count +fi + +# Print the total line count +echo "Total lines of code: $formatted_count" diff --git a/settings.json b/settings.json old mode 100755 new mode 100644