-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-> Added a script so you can count how many lines of code the app has :)
- Loading branch information
Showing
4 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
Empty file.