Skip to content

Commit ca952f3

Browse files
committed
fix coverage
1 parent ba66b0f commit ca952f3

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/idom/client/_private.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@
1616
IDOM_CLIENT_IMPORT_SOURCE_URL_INFIX = "/_snowpack/pkg"
1717

1818

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!
2735

2836

2937
def get_user_packages_file(app_dir: Path) -> Path:

0 commit comments

Comments
 (0)