1515from invoke import task
1616from invoke .context import Context
1717from invoke .exceptions import Exit
18+ from invoke .runners import Result
1819
1920# --- Typing Preamble ------------------------------------------------------------------
2021
@@ -286,7 +287,9 @@ def get_packages(context: Context) -> dict[str, PackageInfo]:
286287
287288def make_py_pkg_info (context : Context , pkg_dir : Path ) -> PackageInfo :
288289 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+ )
290293 return PackageInfo (
291294 name = proj_metadata ["name" ],
292295 path = pkg_dir ,
@@ -329,7 +332,9 @@ def get_current_tags(context: Context) -> set[str]:
329332 line
330333 for line in map (
331334 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 (),
333338 )
334339 if line
335340 }
@@ -418,7 +423,7 @@ def publish(dry_run: bool):
418423
419424 context .run (
420425 "twine upload dist/*" ,
421- env_dict = {
426+ env = {
422427 "TWINE_USERNAME" : twine_username ,
423428 "TWINE_PASSWORD" : twine_password ,
424429 },
@@ -444,3 +449,10 @@ def install_poetry_project(context: Context, path: Path) -> None:
444449 ]
445450 context .run ("pip install -e ." )
446451 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