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
@@ -286,7 +287,9 @@ def get_packages(context: Context) -> dict[str, PackageInfo]:
286
287
287
288
def make_py_pkg_info (context : Context , pkg_dir : Path ) -> PackageInfo :
288
289
with context .cd (pkg_dir ):
289
- proj_metadata = json .loads (context .run ("hatch project metadata" ).stdout )
290
+ proj_metadata = json .loads (
291
+ ensure_result (context , "hatch project metadata" ).stdout
292
+ )
290
293
return PackageInfo (
291
294
name = proj_metadata ["name" ],
292
295
path = pkg_dir ,
@@ -329,7 +332,9 @@ def get_current_tags(context: Context) -> set[str]:
329
332
line
330
333
for line in map (
331
334
str .strip ,
332
- context .run ("git tag --points-at HEAD" , hide = True ).stdout .splitlines (),
335
+ ensure_result (
336
+ context , "git tag --points-at HEAD" , hide = True
337
+ ).stdout .splitlines (),
333
338
)
334
339
if line
335
340
}
@@ -418,7 +423,7 @@ def publish(dry_run: bool):
418
423
419
424
context .run (
420
425
"twine upload dist/*" ,
421
- env_dict = {
426
+ env = {
422
427
"TWINE_USERNAME" : twine_username ,
423
428
"TWINE_PASSWORD" : twine_password ,
424
429
},
@@ -444,3 +449,10 @@ def install_poetry_project(context: Context, path: Path) -> None:
444
449
]
445
450
context .run ("pip install -e ." )
446
451
context .run (f"pip install { ' ' .join (packages_to_install )} " )
452
+
453
+
454
+ def ensure_result (context : Context , * args : Any , ** kwargs : Any ) -> Result :
455
+ result = context .run (* args , ** kwargs )
456
+ if result is None :
457
+ raise Exit ("Command failed" )
458
+ return result
0 commit comments