|
16 | 16 | IDOM_CLIENT_IMPORT_SOURCE_URL_INFIX = "/_snowpack/pkg"
|
17 | 17 |
|
18 | 18 |
|
19 |
| -if not IDOM_CLIENT_BUILD_DIR.current.exists(): |
20 |
| - # populate the runtime build directory if it doesn't exist |
21 |
| - shutil.copytree(BACKUP_BUILD_DIR, IDOM_CLIENT_BUILD_DIR.current, symlinks=True) |
22 |
| -elif getmtime(BACKUP_BUILD_DIR) > getmtime(IDOM_CLIENT_BUILD_DIR.current): |
23 |
| - # delete the existing runtime build because it's out of date |
24 |
| - shutil.rmtree(IDOM_CLIENT_BUILD_DIR.current) |
25 |
| - # replace it with the newer backup build (presumable from a fresh install) |
26 |
| - shutil.copytree(BACKUP_BUILD_DIR, IDOM_CLIENT_BUILD_DIR.current, symlinks=True) |
| 19 | +def _run_build_dir_init_only_once(): # pragma: no cover |
| 20 | + """Initialize the runtime build directory |
| 21 | +
|
| 22 | + This should only be called *once* |
| 23 | + """ |
| 24 | + if not IDOM_CLIENT_BUILD_DIR.current.exists(): |
| 25 | + # populate the runtime build directory if it doesn't exist |
| 26 | + shutil.copytree(BACKUP_BUILD_DIR, IDOM_CLIENT_BUILD_DIR.current, symlinks=True) |
| 27 | + elif getmtime(BACKUP_BUILD_DIR) > getmtime(IDOM_CLIENT_BUILD_DIR.current): |
| 28 | + # delete the existing runtime build because it's out of date |
| 29 | + shutil.rmtree(IDOM_CLIENT_BUILD_DIR.current) |
| 30 | + # replace it with the newer backup build (presumable from a fresh install) |
| 31 | + shutil.copytree(BACKUP_BUILD_DIR, IDOM_CLIENT_BUILD_DIR.current, symlinks=True) |
| 32 | + |
| 33 | + |
| 34 | +_run_build_dir_init_only_once() # this is only ever called once! |
27 | 35 |
|
28 | 36 |
|
29 | 37 | def get_user_packages_file(app_dir: Path) -> Path:
|
|
0 commit comments