Skip to content

Commit b881d4c

Browse files
committed
fix: start web dev server script
1 parent bbedecb commit b881d4c

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Script/start_editor_web_dev_server.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from sys import argv
66
from pathlib import Path
77

8-
def get_nodejs_version():
9-
third_party_cmake = Path(argv[0]).parent.parent / 'ThirdParty' / 'CMakeLists.txt'
8+
def get_nodejs_version(py_path):
9+
third_party_cmake = Path(py_path).parent.parent / 'ThirdParty' / 'CMakeLists.txt'
1010
if not third_party_cmake.exists():
1111
raise RuntimeError('Third-party CMakeLists.txt not found')
1212

@@ -24,15 +24,15 @@ def get_nodejs_version():
2424
return found[0]
2525

2626

27-
def get_nodejs_root(nodejs_version):
28-
nodejs_root = Path(argv[0]).parent.parent / 'ThirdParty' / 'Lib' / '{}-{}-{}'.format('Nodejs', platform.system(), nodejs_version)
27+
def get_nodejs_root(py_path, nodejs_version):
28+
nodejs_root = Path(py_path).parent.parent / 'ThirdParty' / 'Lib' / '{}-{}-{}'.format('Nodejs', platform.system(), nodejs_version)
2929
if not nodejs_root.exists():
3030
raise RuntimeError('Root of node.js not found')
3131
return nodejs_root
3232

3333

34-
def get_web_project_root():
35-
web_project_root = Path(argv[0]).parent.parent / 'Editor' / 'Web'
34+
def get_web_project_root(py_path):
35+
web_project_root = Path(py_path).parent.parent / 'Editor' / 'Web'
3636
return web_project_root
3737

3838

@@ -50,10 +50,12 @@ def start_dev_server(nodejs_root, web_project_root):
5050

5151

5252
if __name__ == '__main__':
53-
nodejs_version = get_nodejs_version()
54-
print('Node.js version: ', nodejs_version)
55-
nodejs_root = get_nodejs_root(nodejs_version)
56-
print('Node.js root: ', nodejs_root)
57-
web_project_root = get_web_project_root()
58-
print('Web project root: ', web_project_root)
53+
py_path = os.path.realpath(__file__)
54+
print('Python File Path:', py_path)
55+
nodejs_version = get_nodejs_version(py_path)
56+
print('Node.js version:', nodejs_version)
57+
nodejs_root = get_nodejs_root(py_path, nodejs_version)
58+
print('Node.js root:', nodejs_root)
59+
web_project_root = get_web_project_root(py_path)
60+
print('Web project root:', web_project_root)
5961
start_dev_server(nodejs_root, web_project_root)

0 commit comments

Comments
 (0)