Update nodes.py

allow custom_nodes to set a styles directory for css
This commit is contained in:
someghuser 2023-11-28 23:46:01 +08:00 committed by GitHub
parent a667638442
commit f23bd87e47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -1779,6 +1779,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
}
EXTENSION_WEB_DIRS = {}
EXTENSION_STYLE_DIRS = {}
def load_custom_node(module_path, ignore=set()):
module_name = os.path.basename(module_path)
@ -1797,6 +1798,11 @@ def load_custom_node(module_path, ignore=set()):
sys.modules[module_name] = module
module_spec.loader.exec_module(module)
if hasattr(module, "STYLE_DIRECTORY") and getattr(module, "STYLE_DIRECTORY") is not None:
style_dir = os.path.abspath(os.path.join(module_dir, getattr(module, "STYLE_DIRECTORY")))
if os.path.isdir(style_dir):
EXTENSION_STYLE_DIRS[module_name] = style_dir
if hasattr(module, "WEB_DIRECTORY") and getattr(module, "WEB_DIRECTORY") is not None:
web_dir = os.path.abspath(os.path.join(module_dir, getattr(module, "WEB_DIRECTORY")))
if os.path.isdir(web_dir):