Created
April 12, 2024 08:58
-
-
Save vgeorge/19961c1177b55893820fdf103e3c4ce1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
cd app | |
# Count JavaScript and JSX files | |
js_files=$(find . -type f \( -name "*.js" -o -name "*.jsx" \)) | |
js_count=$(echo "$js_files" | wc -l) | |
# Count TypeScript and TSX files | |
ts_files=$(find . -type f \( -name "*.ts" -o -name "*.tsx" \)) | |
ts_count=$(echo "$ts_files" | wc -l) | |
# Calculate total number of files | |
total_files=$((js_count + ts_count)) | |
# Calculate percentages | |
js_file_percentage=$(echo "scale=2; ($js_count / $total_files) * 100" | bc) | |
# Count lines of code in JavaScript and JSX files | |
js_lines=$(cat $js_files 2>/dev/null | wc -l) | |
# Count lines of code in TypeScript and TSX files | |
ts_lines=$(cat $ts_files 2>/dev/null | wc -l) | |
# Calculate total lines of code | |
total_lines=$((js_lines + ts_lines)) | |
# Calculate percentages | |
js_line_percentage=$(echo "scale=2; ($js_lines / $total_lines) * 100" | bc) | |
# Print the results | |
echo "Number of files in JS: $js_count ($js_file_percentage% of total files)" | |
echo "Number of lines of code in JS: $js_lines ($js_line_percentage% of total lines)" | |
# List the 10 smallest JavaScript and JSX files by size | |
echo "Listing the 10 smallest JavaScript and JSX files:" | |
find . -type f \( -name "*.js" -o -name "*.jsx" \) -exec ls -lS {} + | sort -k 5 -n | head -n 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment