Improved start command to use workspace

This commit is contained in:
Sven Heidemann 2021-04-07 18:19:55 +02:00
parent 6a5c832288
commit d9bd7911ef
3 changed files with 10 additions and 5 deletions

View File

@ -19,4 +19,4 @@ class StartService(CommandABC):
:param args: :param args:
:return: :return:
""" """
self._live_server.start() self._live_server.start(args)

View File

@ -29,6 +29,8 @@ class LiveServerService(FileSystemEventHandler):
self._ls_thread = None self._ls_thread = None
self._observer = None self._observer = None
self._args: list[str] = []
def _start_observer(self): def _start_observer(self):
""" """
Starts the file changes observer Starts the file changes observer
@ -70,15 +72,17 @@ class LiveServerService(FileSystemEventHandler):
def _start(self): def _start(self):
self._start_observer() self._start_observer()
self._ls_thread = LiveServerThread(self._src_dir, self._build_settings) self._ls_thread = LiveServerThread(self._src_dir, self._build_settings, self._args)
self._ls_thread.start() self._ls_thread.start()
self._ls_thread.join() self._ls_thread.join()
Console.close() Console.close()
def start(self): def start(self, args: list[str]):
""" """
Starts the CPL live development server Starts the CPL live development server
:param args:
:return: :return:
""" """
self._args = args
Console.write_line('** CPL live development server is running **') Console.write_line('** CPL live development server is running **')
self._start() self._start()

View File

@ -11,7 +11,7 @@ from cpl_cli.configuration import BuildSettings
class LiveServerThread(threading.Thread): class LiveServerThread(threading.Thread):
def __init__(self, path: str, build_settings: BuildSettings): def __init__(self, path: str, build_settings: BuildSettings, args: list[str]):
""" """
Thread to start the CPL project for the live development server Thread to start the CPL project for the live development server
:param path: :param path:
@ -20,6 +20,7 @@ class LiveServerThread(threading.Thread):
self._path = path self._path = path
self._build_settings = build_settings self._build_settings = build_settings
self._args = args
self._main = '' self._main = ''
self._command = [] self._command = []
@ -58,5 +59,5 @@ class LiveServerThread(threading.Thread):
env_vars['PYTHONPATH'] = f'{os.path.dirname(self._path)}:' \ env_vars['PYTHONPATH'] = f'{os.path.dirname(self._path)}:' \
f'{os.path.join(os.path.dirname(self._path), self._build_settings.source_path)}' f'{os.path.join(os.path.dirname(self._path), self._build_settings.source_path)}'
self._command = [sys.executable, self._main, ''.join(sys.argv[2:])] self._command = [sys.executable, self._main, ''.join(self._args)]
subprocess.run(self._command, env=env_vars) subprocess.run(self._command, env=env_vars)