magicciv/scripts/run/format.sh

34 lines
846 B
Bash
Raw Normal View History

#!/usr/bin/env bash
# Format subcommands.
#
# Split out of dev.sh. Each per-language formatter is independently
# callable (`./run format:gd`, `format:rust`, `format:ts`) or via the
# umbrella `./run format` which runs all three.
cmd_format_gd() {
echo -e "${BLUE}GDScript format (gdformat)...${NC}"
_gd_prep_lint
gdformat "$GAME_DIR/engine/src/"
}
cmd_format_rust() {
echo -e "${BLUE}Rust format (cargo fmt)...${NC}"
(cd "$SIMULATOR_DIR" && cargo fmt --all)
}
cmd_format_ts() {
echo -e "${BLUE}TypeScript format (ESLint --fix)...${NC}"
pnpm --prefix "$GUIDE_DIR" lint:fix
}
cmd_format() {
echo -e "${BLUE}[1/3] GDScript format${NC}"
cmd_format_gd
echo ""
echo -e "${BLUE}[2/3] Rust format${NC}"
cmd_format_rust
echo ""
echo -e "${BLUE}[3/3] TypeScript format${NC}"
cmd_format_ts
}