|
15 | 15 | from invoke import task
|
16 | 16 | from invoke.context import Context
|
17 | 17 | from invoke.exceptions import Exit
|
| 18 | +from invoke.runners import Result |
18 | 19 |
|
19 | 20 | # --- Typing Preamble ------------------------------------------------------------------
|
20 | 21 |
|
@@ -278,7 +279,9 @@ def get_packages(context: Context) -> dict[str, PackageInfo]:
|
278 | 279 |
|
279 | 280 | def make_py_pkg_info(context: Context, pkg_dir: Path) -> PackageInfo:
|
280 | 281 | with context.cd(pkg_dir):
|
281 |
| - proj_metadata = json.loads(context.run("hatch project metadata").stdout) |
| 282 | + proj_metadata = json.loads( |
| 283 | + ensure_result(context, "hatch project metadata").stdout |
| 284 | + ) |
282 | 285 | return PackageInfo(
|
283 | 286 | name=proj_metadata["name"],
|
284 | 287 | path=pkg_dir,
|
@@ -321,7 +324,9 @@ def get_current_tags(context: Context) -> set[str]:
|
321 | 324 | line
|
322 | 325 | for line in map(
|
323 | 326 | str.strip,
|
324 |
| - context.run("git tag --points-at HEAD", hide=True).stdout.splitlines(), |
| 327 | + ensure_result( |
| 328 | + context, "git tag --points-at HEAD", hide=True |
| 329 | + ).stdout.splitlines(), |
325 | 330 | )
|
326 | 331 | if line
|
327 | 332 | }
|
@@ -417,3 +422,10 @@ def publish(dry_run: bool):
|
417 | 422 | )
|
418 | 423 |
|
419 | 424 | return publish
|
| 425 | + |
| 426 | + |
| 427 | +def ensure_result(context: Context, *args: Any, **kwargs: Any) -> Result: |
| 428 | + result = context.run(*args, **kwargs) |
| 429 | + if result is None: |
| 430 | + raise Exit("Command failed") |
| 431 | + return result |
0 commit comments