diff --git a/poetry_monoranger_plugin/monorepo_adder.py b/poetry_monoranger_plugin/monorepo_adder.py index 2639e67..d18fb74 100644 --- a/poetry_monoranger_plugin/monorepo_adder.py +++ b/poetry_monoranger_plugin/monorepo_adder.py @@ -145,11 +145,21 @@ def post_execute(self, event: ConsoleTerminateEvent): installer.whitelist([poetry.package.name]) - status = installer.run() - - if status != 0 and not command.option("dry-run") and self.pre_add_pyproject is not None: - io.write_line("An error occurred during the installation. Rolling back changes...") - assert isinstance(self.pre_add_pyproject, TOMLDocument) - poetry.file.write(self.pre_add_pyproject) - - event.set_exit_code(status) + last_exc = None + status = 0 + + try: + status = installer.run() + except Exception as e: + last_exc = e + status = 1 + finally: + if status != 0 and not command.option("dry-run") and self.pre_add_pyproject is not None: + io.write_line("\nAn error occurred during the installation. Rolling back changes...") + assert isinstance(self.pre_add_pyproject, TOMLDocument) + poetry.file.write(self.pre_add_pyproject) + + if last_exc is not None: + raise last_exc + + event.set_exit_code(status) diff --git a/pyproject.toml b/pyproject.toml index 005a790..83b3751 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "poetry-monoranger-plugin" -version = "0.1.1" +version = "0.1.2" description = "Monoranger is a plugin for Poetry that helps you manage your monorepo, enabling shared lockfiles and virtual environments." license = "Apache-2.0" authors = ["Andreas Georgiou "]