(
*,
reload_callback: ReloadCallback,
env_path: str | Path = ENV_PATH,
env_example_path: str | Path = ENV_EXAMPLE_PATH,
)
| 657 | |
| 658 | |
| 659 | async def reset_env_to_example( |
| 660 | *, |
| 661 | reload_callback: ReloadCallback, |
| 662 | env_path: str | Path = ENV_PATH, |
| 663 | env_example_path: str | Path = ENV_EXAMPLE_PATH, |
| 664 | ) -> None: |
| 665 | example_path = Path(env_example_path) |
| 666 | if not example_path.exists(): |
| 667 | raise FileNotFoundError(".env.example 不存在") |
| 668 | |
| 669 | example_content = example_path.read_text(encoding="utf-8") |
| 670 | |
| 671 | def _writer(target_path: Path) -> None: |
| 672 | content = example_content.rstrip("\n") |
| 673 | target_path.write_text( |
| 674 | f"{content}\n" if content else "", |
| 675 | encoding="utf-8", |
| 676 | ) |
| 677 | |
| 678 | await _apply_env_change( |
| 679 | _writer, |
| 680 | reload_callback=reload_callback, |
| 681 | env_path=env_path, |
| 682 | ) |
no test coverage detected