This commit is contained in:
1 parent
5419d15518
commit
2a42d0245a
14 files changed
+805
-201
No files matched your search
+28
-36
@@ -37,24 +37,23 @@ if [[ "${OS:-}" == "Windows_NT" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Nastavitev imena izhodne datoteke
|
||||
OUTPUT_FILE="${1:-code_export.txt}"
|
||||
OUTPUT_PATH="$SCRIPT_DIR/$OUTPUT_FILE"
|
||||
|
||||
# Odstrani izhodno datoteko, če že obstaja, da začnemo s čisto datoteko
|
||||
if [ -f "$OUTPUT_FILE" ]; then
|
||||
rm "$OUTPUT_FILE"
|
||||
fi
|
||||
rm -f "$OUTPUT_PATH"
|
||||
|
||||
# Poišči vse datoteke, razen skritih datotek in določenih map (npr. node_modules).
|
||||
# Dodane so izjeme za slike, videoposnetke, PDF-je, arhive in druge binarne datoteke
|
||||
# neposredno v ukaz 'find' za boljšo zmogljivost.
|
||||
find . -type f \
|
||||
find "$SCRIPT_DIR" -type f \
|
||||
-not -path "*/\.*" \
|
||||
-not -path "*node_modules*" \
|
||||
-not -path "*vendor*" \
|
||||
-not -path "*dist*" \
|
||||
-not -path "*build*" \
|
||||
-not -path "*/node_modules/*" \
|
||||
-not -path "*/vendor/*" \
|
||||
-not -path "*/dist/*" \
|
||||
-not -path "*/build/*" \
|
||||
-not -path "*/images/*" \
|
||||
-not -name "code_export*.txt" \
|
||||
-not -name "gitea-token*.txt" \
|
||||
-not -name "gitea-token*.txt.sig" \
|
||||
-not -name "export_code.sh" \
|
||||
-not -name "export_code.ps1" \
|
||||
-not -iname "*.jpg" -not -iname "*.jpeg" \
|
||||
-not -iname "*.png" -not -iname "*.gif" \
|
||||
-not -iname "*.bmp" -not -iname "*.tiff" \
|
||||
@@ -66,36 +65,29 @@ find . -type f \
|
||||
-not -iname "*.mp3" -not -iname "*.wav" \
|
||||
-not -iname "*.ogg" -not -iname "*.flac" \
|
||||
-not -iname "*.pdf" \
|
||||
-not -iname "*.zip" \
|
||||
-not -iname "*.tar" \
|
||||
-not -iname "*.gz" \
|
||||
-not -iname "*.bz2" \
|
||||
-not -iname "*.rar" \
|
||||
-not -iname "*.7z" \
|
||||
-not -iname "*.zip" -not -iname "*.tar" \
|
||||
-not -iname "*.gz" -not -iname "*.bz2" \
|
||||
-not -iname "*.rar" -not -iname "*.7z" \
|
||||
-not -iname "*.doc" -not -iname "*.docx" \
|
||||
-not -iname "*.xls" -not -iname "*.xlsx" \
|
||||
-not -iname "*.ppt" -not -iname "*.pptx" \
|
||||
-not -iname "*.eot" -not -iname "*.ttf" \
|
||||
-not -iname "*.woff" -not -iname "*.woff2" \
|
||||
| sort | while read -r file; do
|
||||
|
||||
# Preskoči samo izhodno datoteko in to skripto
|
||||
if [[ "$file" == "./$OUTPUT_FILE" || "$file" == "./export_code.sh" || "$file" == "./export_code.ps1" ]]; then
|
||||
| sort | while IFS= read -r file; do
|
||||
|
||||
rel_path="./${file#"$SCRIPT_DIR"/}"
|
||||
|
||||
if file --mime-type -b "$file" | grep -qiE '^(image|video|audio|application/octet-stream)'; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Dodatna varnostna preverba: preskoči slikovne datoteke po MIME tipu
|
||||
if file --mime-type -b "$file" | grep -qiE '^(image)/'; then
|
||||
continue
|
||||
|
||||
printf '"%s" : \n' "$rel_path" >> "$OUTPUT_PATH"
|
||||
printf '"""\n' >> "$OUTPUT_PATH"
|
||||
cat "$file" >> "$OUTPUT_PATH"
|
||||
if [[ -n "$(tail -c 1 "$file" 2>/dev/null || true)" ]]; then
|
||||
printf '\n' >> "$OUTPUT_PATH"
|
||||
fi
|
||||
|
||||
# Dodaj ime datoteke in njeno vsebino v izhodno datoteko
|
||||
echo "\"$file\" : " >> "$OUTPUT_FILE"
|
||||
echo "\"\"\"" >> "$OUTPUT_FILE"
|
||||
cat "$file" >> "$OUTPUT_FILE"
|
||||
echo "\"\"\"" >> "$OUTPUT_FILE"
|
||||
echo "" >> "$OUTPUT_FILE"
|
||||
echo "" >> "$OUTPUT_FILE"
|
||||
printf '"""\n\n\n' >> "$OUTPUT_PATH"
|
||||
done
|
||||
|
||||
echo "Izvoz kode končan. Vsebina je shranjena v datoteko $OUTPUT_FILE"
|
||||
echo "Code export finished. Output saved to $OUTPUT_PATH"
|
||||
Reference in new issue
Block a user