-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist-files.sh
More file actions
73 lines (63 loc) · 1.15 KB
/
list-files.sh
File metadata and controls
73 lines (63 loc) · 1.15 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
BLACKLIST_DIRS=(
"node_modules"
"public"
".next"
".git"
"coverage"
"build"
"dist"
"cypress/videos"
)
BLACKLIST_FILES=(
".env"
".env.local"
".gitignore"
"README.md"
"LICENSE"
"yarn.lock"
"package-lock.json"
"react-project-content.bash"
)
BLACKLIST_EXTENSIONS=(
"md"
"txt"
"pdf"
"log"
)
is_in_blacklisted_dir() {
local f="$1"
for d in "${BLACKLIST_DIRS[@]}"; do
[[ "$f" == "$d/"* || "$f" == */"$d/"* || "$f" == */"$d"* ]] && return 0
done
return 1
}
is_blacklisted_file() {
local f="$(basename "$1")"
for b in "${BLACKLIST_FILES[@]}"; do
[[ "$f" == "$b" ]] && return 0
done
return 1
}
is_blacklisted_extension() {
local ext="${1##*.}"
for e in "${BLACKLIST_EXTENSIONS[@]}"; do
[[ "$ext" == "$e" ]] && return 0
done
return 1
}
echo "["
first=1
while IFS= read -r file; do
rel="${file#./}"
if is_in_blacklisted_dir "$rel"; then continue; fi
if is_blacklisted_file "$rel"; then continue; fi
if is_blacklisted_extension "$rel"; then continue; fi
if [ $first -eq 0 ]; then
echo ","
fi
echo -n " \"$rel\""
first=0
done < <(find . -type f | sort)
echo
echo "]"