Files
starRiverProperty/frontend-source/scripts/beautify-all.sh
T
反编译工作区 4f79e10bd6 chore: cleanup stray nested directories in frontend-source
Former-commit-id: 376f94edd602d3dfed1cbada6e08361ee7b08e73
2026-04-29 13:07:40 +08:00

26 lines
730 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Simple, conservative beautifier runner for alarm-front decompilation.
# If the real beautifier is unavailable, gracefully copy input to output.
INPUT_DIR="$1"
OUTPUT_DIR="$2"
if [ -z "${INPUT_DIR:-}" ] || [ -z "${OUTPUT_DIR:-}" ]; then
echo "Usage: $0 <input-dir> <output-dir>" >&2
exit 1
fi
mkdir -p "$OUTPUT_DIR"
shopt -s nullglob
for f in "$INPUT_DIR"/*.js; do
[ -f "$f" ] || continue
# Try to beautify with existing local tool if available, else copy as-is
if [ -x "$OUTPUT_DIR"/../node_modules/.bin/js-beautify ]; then
"$OUTPUT_DIR"/../node_modules/.bin/js-beautify "$f" -r > "$OUTPUT_DIR/$(basename "$f")"
else
cp "$f" "$OUTPUT_DIR/$(basename "$f")"
fi
done