Save the project configuration to disk. Creates the .autoforge directory if it doesn't exist. Args: project_dir: Path to the project directory. config: Configuration dictionary to save. Raises: OSError: If the file cannot be written.
(project_dir: Path, config: dict)
| 143 | |
| 144 | |
| 145 | def _save_config(project_dir: Path, config: dict) -> None: |
| 146 | """ |
| 147 | Save the project configuration to disk. |
| 148 | |
| 149 | Creates the .autoforge directory if it doesn't exist. |
| 150 | |
| 151 | Args: |
| 152 | project_dir: Path to the project directory. |
| 153 | config: Configuration dictionary to save. |
| 154 | |
| 155 | Raises: |
| 156 | OSError: If the file cannot be written. |
| 157 | """ |
| 158 | config_path = _get_config_path(project_dir) |
| 159 | |
| 160 | # Ensure the .autoforge directory exists |
| 161 | config_path.parent.mkdir(parents=True, exist_ok=True) |
| 162 | |
| 163 | try: |
| 164 | with open(config_path, "w", encoding="utf-8") as f: |
| 165 | json.dump(config, f, indent=2) |
| 166 | logger.debug("Saved config to %s", config_path) |
| 167 | except OSError as e: |
| 168 | logger.error("Failed to save config to %s: %s", config_path, e) |
| 169 | raise |
| 170 | |
| 171 | |
| 172 | # ============================================================================= |
no test coverage detected