2022.6.14 - Pre & Post build scripts #79
@ -5,8 +5,6 @@ import traceback
|
||||
from collections.abc import Callable
|
||||
from typing import Union, Type, Optional
|
||||
|
||||
from cpl_cli.command.custom_script_service import CustomScriptService
|
||||
from cpl_cli.configuration import WorkspaceSettings
|
||||
from cpl_core.configuration.argument_abc import ArgumentABC
|
||||
from cpl_core.configuration.argument_builder import ArgumentBuilder
|
||||
from cpl_core.configuration.argument_executable_abc import ArgumentExecutableABC
|
||||
@ -158,6 +156,8 @@ class Configuration(ConfigurationABC):
|
||||
|
||||
def _handle_pre_or_post_executables(self, pre: bool, argument: ExecutableArgument, services: ServiceProviderABC):
|
||||
script_type = 'pre-' if pre else 'post-'
|
||||
|
||||
from cpl_cli.configuration.workspace_settings import WorkspaceSettings
|
||||
workspace: Optional[WorkspaceSettings] = self.get_configuration(WorkspaceSettings)
|
||||
if workspace is None or len(workspace.scripts) == 0:
|
||||
return
|
||||
@ -170,12 +170,13 @@ class Configuration(ConfigurationABC):
|
||||
if script.split(script_type)[1] != argument.name:
|
||||
continue
|
||||
|
||||
from cpl_cli.command.custom_script_service import CustomScriptService
|
||||
css: CustomScriptService = services.get_service(CustomScriptService)
|
||||
if css is None:
|
||||
continue
|
||||
|
||||
Console.write_line()
|
||||
self.add_configuration('ACTIVE_EXECUTABLE', script)
|
||||
self._set_variable('ACTIVE_EXECUTABLE', script)
|
||||
css.run([])
|
||||
|
||||
def _parse_arguments(self, executables: list[ArgumentABC], arg_list: list[str], args_types: list[ArgumentABC]):
|
||||
@ -333,7 +334,7 @@ class Configuration(ConfigurationABC):
|
||||
|
||||
cmd: ArgumentExecutableABC = services.get_service(exe.executable_type)
|
||||
self._handle_pre_or_post_executables(True, exe, services)
|
||||
self.add_configuration('ACTIVE_EXECUTABLE', exe.name)
|
||||
self._set_variable('ACTIVE_EXECUTABLE', exe.name)
|
||||
cmd.execute(self._additional_arguments)
|
||||
self._handle_pre_or_post_executables(False, exe, services)
|
||||
prevent = exe.prevent_next_executable
|
||||
|
Loading…
Reference in New Issue
Block a user