2021.4.6 #25
@ -19,4 +19,4 @@ class StartService(CommandABC):
|
||||
:param args:
|
||||
:return:
|
||||
"""
|
||||
self._live_server.start()
|
||||
self._live_server.start(args)
|
||||
|
@ -29,6 +29,8 @@ class LiveServerService(FileSystemEventHandler):
|
||||
self._ls_thread = None
|
||||
self._observer = None
|
||||
|
||||
self._args: list[str] = []
|
||||
|
||||
def _start_observer(self):
|
||||
"""
|
||||
Starts the file changes observer
|
||||
@ -70,15 +72,17 @@ class LiveServerService(FileSystemEventHandler):
|
||||
|
||||
def _start(self):
|
||||
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.join()
|
||||
Console.close()
|
||||
|
||||
def start(self):
|
||||
def start(self, args: list[str]):
|
||||
"""
|
||||
Starts the CPL live development server
|
||||
:param args:
|
||||
:return:
|
||||
"""
|
||||
self._args = args
|
||||
Console.write_line('** CPL live development server is running **')
|
||||
self._start()
|
||||
|
@ -11,7 +11,7 @@ from cpl_cli.configuration import BuildSettings
|
||||
|
||||
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
|
||||
:param path:
|
||||
@ -20,6 +20,7 @@ class LiveServerThread(threading.Thread):
|
||||
|
||||
self._path = path
|
||||
self._build_settings = build_settings
|
||||
self._args = args
|
||||
|
||||
self._main = ''
|
||||
self._command = []
|
||||
@ -58,5 +59,5 @@ class LiveServerThread(threading.Thread):
|
||||
env_vars['PYTHONPATH'] = f'{os.path.dirname(self._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)
|
||||
|
Loading…
Reference in New Issue
Block a user