|
10 | 10 | from codeflash.code_utils import env_utils |
11 | 11 | from codeflash.code_utils.code_utils import exit_with_message, normalize_ignore_paths |
12 | 12 | from codeflash.code_utils.config_parser import parse_config_file |
| 13 | +from codeflash.languages import set_current_language |
13 | 14 | from codeflash.languages.test_framework import set_current_test_framework |
14 | 15 | from codeflash.lsp.helpers import is_LSP_enabled |
15 | 16 | from codeflash.version import __version__ as version |
@@ -108,10 +109,18 @@ def process_pyproject_config(args: Namespace) -> Namespace: |
108 | 109 | assert args.module_root is not None, "--module-root must be specified" |
109 | 110 | assert Path(args.module_root).is_dir(), f"--module-root {args.module_root} must be a valid directory" |
110 | 111 |
|
111 | | - # For JS/TS projects, tests_root is optional (Jest auto-discovers tests) |
112 | | - # Default to module_root if not specified |
113 | | - is_js_ts_project = pyproject_config.get("language") in ("javascript", "typescript") |
114 | | - is_java_project = pyproject_config.get("language") == "java" |
| 112 | + # Determine project language from explicit config or config file name. |
| 113 | + # Java projects use codeflash.toml but don't always have an explicit language field. |
| 114 | + config_language = pyproject_config.get("language") |
| 115 | + if config_language is None and pyproject_file_path.name == "codeflash.toml": |
| 116 | + config_language = "java" |
| 117 | + is_js_ts_project = config_language in ("javascript", "typescript") |
| 118 | + is_java_project = config_language == "java" |
| 119 | + |
| 120 | + # Set the language singleton early so downstream code (e.g. get_git_diff) |
| 121 | + # can use current_language_support() before function discovery. |
| 122 | + if config_language: |
| 123 | + set_current_language(config_language) |
115 | 124 |
|
116 | 125 | # Set the test framework singleton for JS/TS projects |
117 | 126 | if is_js_ts_project and pyproject_config.get("test_framework"): |
|
0 commit comments