-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathshow-new-language-files.sh
executable file
·36 lines (27 loc) · 1.01 KB
/
show-new-language-files.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Get the absolute path of the directory where this script is located
SCRIPT_DIR="$(dirname "$(grealpath "$0")")"
# Set the relative subfolder path
SUBFOLDER="$SCRIPT_DIR/../unpacked/"
# Navigate to the Git repository root
cd "$(git rev-parse --show-toplevel)"
echo "Checking for newly added files..."
# Get list of newly added files that are within the specific subfolder
new_files=$(git diff --name-only HEAD | grep "$(grealpath --relative-to="$(pwd)" "$SUBFOLDER")")
# echo "$new_files"
declare -a matching_files
for file in $new_files; do
# Check the first 10 lines of each file for the specific pattern
if head -n 10 "$file" | grep -q 'e.exports = JSON.parse('; then
# echo " $file"
# head -n 6 $file
matching_files+=("$file")
fi
done
# Sort the array by extracting numbers and using them as sort keys
IFS=$'\n' sorted_files=($(printf '%s\n' "${matching_files[@]}" | sort -t '/' -k 5n))
unset IFS
echo "Language files (sorted):"
for file in "${sorted_files[@]}"; do
echo " $file"
done