fix: auto-install in empty or new directories without requiring --force

- Allow seamless 1-line curl installation in empty or newly created test folders
- Prevent early exit when target directory has 2 or fewer files
- Fix argument parsing for target directory and flags

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-08 09:17:38 +07:00
parent 4da2d45af3
commit c8edce44ea
+8 -3
View File
@@ -172,9 +172,14 @@ if [ ! -d "$TARGET_DIR" ]; then
fi
if [ ! -f "$TARGET_DIR/artisan" ] && [ ! -f "$TARGET_DIR/composer.json" ]; then
if [ "$FORCE_MODE" = false ]; then
echo -e "${YELLOW}⚠️ Cảnh báo: Thư mục '$TARGET_DIR' chưa có file artisan hoặc composer.json.${NC}"
echo -e "Nếu bạn vẫn muốn cài đặt vào thư mục này, hãy thêm cờ: ${GREEN}--force${NC}"
# Kiểm tra xem thư mục có trống hoặc là thư mục mới không
FILE_COUNT=$(ls -A "$TARGET_DIR" 2>/dev/null | wc -l | tr -d ' ')
if [ "$FILE_COUNT" -le 2 ]; then
echo -e "${YELLOW}ℹ Thư mục mới/trống: Tự động khởi tạo bộ công cụ Unit Test...${NC}"
elif [ "$FORCE_MODE" = false ]; then
echo -e "${YELLOW}⚠️ Cảnh báo: Thư mục '$TARGET_DIR' đang chứa dữ liệu khác và chưa có file artisan hoặc composer.json.${NC}"
echo -e "Nếu bạn vẫn muốn cài đặt vào thư mục này, hãy chạy:"
echo -e " ${CYAN}bash <(curl -fsSL <URL>/install.sh) --force${NC}"
exit 1
fi
fi