()
| 119 | |
| 120 | |
| 121 | def install_js(): |
| 122 | src_dir = get_ext_dir("web/js") |
| 123 | if not os.path.exists(src_dir): |
| 124 | log("No JS") |
| 125 | return |
| 126 | |
| 127 | should_install = should_install_js() |
| 128 | if should_install: |
| 129 | log("it looks like you're running an old version of ComfyUI that requires manual setup of web files, it is recommended you update your installation.", "warning", True) |
| 130 | dst_dir = get_web_ext_dir() |
| 131 | linked = os.path.islink(dst_dir) or is_junction(dst_dir) |
| 132 | if linked or os.path.exists(dst_dir): |
| 133 | if linked: |
| 134 | if should_install: |
| 135 | log("JS already linked") |
| 136 | else: |
| 137 | os.unlink(dst_dir) |
| 138 | log("JS unlinked, PromptServer will serve extension") |
| 139 | elif not should_install: |
| 140 | shutil.rmtree(dst_dir) |
| 141 | log("JS deleted, PromptServer will serve extension") |
| 142 | return |
| 143 | |
| 144 | if not should_install: |
| 145 | log("JS skipped, PromptServer will serve extension") |
| 146 | return |
| 147 | |
| 148 | if link_js(src_dir, dst_dir): |
| 149 | log("JS linked") |
| 150 | return |
| 151 | |
| 152 | log("Copying JS files") |
| 153 | shutil.copytree(src_dir, dst_dir, dirs_exist_ok=True) |
| 154 | |
| 155 | |
| 156 | def should_install_js(): |
no test coverage detected