Skip to main content

chives/javascript: don't update JS files in virtualenvs

ID
0ee43e3
date
2026-10-25 08:54:33+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
28a4cbf
message
chives/javascript: don't update JS files in virtualenvs
changed files
8 files, 26 additions, 6 deletions

Changed files

CHANGELOG.md (8289 → 8582)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b635f1c..bdd339e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 # CHANGELOG
 
+## v55 - 2026-10-25
+
+When updating JavaScript files with `chives-update-js`, ignore JavaScript files inside a `.venv` folder.
+
+This is the name I use for my Python virtual environments, which includes the installed copy of chives, and `chives-update-js` shouldn't be touching files in there.
+
 ## v54 - 2026-10-24
 
 Introduce an experimental `verify_local_page_integrity` function in `browser_fixtures`.

javascript/chives-image.js (6561 → 6561)

diff --git a/javascript/chives-image.js b/javascript/chives-image.js
index 3d7b12e..2a03beb 100644
--- a/javascript/chives-image.js
+++ b/javascript/chives-image.js
@@ -1,5 +1,5 @@
 // javascript/chives-image.js
-// chives version: 54
+// chives version: 55
 
 // ChivesImage provides a <chives-image> component that renders
 // an ImageEntity on a web page.

javascript/chives-pagination.js (4929 → 4929)

diff --git a/javascript/chives-pagination.js b/javascript/chives-pagination.js
index 4bf0980..198f61f 100644
--- a/javascript/chives-pagination.js
+++ b/javascript/chives-pagination.js
@@ -1,5 +1,5 @@
 // javascript/chives-pagination.js
-// chives version: 54
+// chives version: 55
 
 // ChivesPagination manages the pagination of a collection of items.
 //

javascript/chives-sorting.js (5034 → 5034)

diff --git a/javascript/chives-sorting.js b/javascript/chives-sorting.js
index 8e390bd..a11da69 100644
--- a/javascript/chives-sorting.js
+++ b/javascript/chives-sorting.js
@@ -1,5 +1,5 @@
 // javascript/chives-sorting.js
-// chives version: 54
+// chives version: 55
 
 // ChivesSorting manages the sorting of a collection of items.
 //

javascript/chives-video.js (5147 → 5147)

diff --git a/javascript/chives-video.js b/javascript/chives-video.js
index 8df28e6..84301f9 100644
--- a/javascript/chives-video.js
+++ b/javascript/chives-video.js
@@ -1,5 +1,5 @@
 // javascript/chives-video.js
-// chives version: 54
+// chives version: 55
 
 // ChivesVideo provides a <chives-video> component that renders
 // a VideoEntity on a web page.

python/chives/__init__.py (391 → 391)

diff --git a/python/chives/__init__.py b/python/chives/__init__.py
index e460306..7943063 100644
--- a/python/chives/__init__.py
+++ b/python/chives/__init__.py
@@ -11,4 +11,4 @@ I share across multiple sites.
 
 """
 
-__version__ = "54"
+__version__ = "55"

python/chives/javascript.py (2354 → 2387)

diff --git a/python/chives/javascript.py b/python/chives/javascript.py
index ae4218a..cc49c5c 100644
--- a/python/chives/javascript.py
+++ b/python/chives/javascript.py
@@ -45,7 +45,7 @@ def update_js_components(root: Path, js_assets: Traversable | Path) -> None:
     """
     print(f"Scanning for chives JavaScript components in: {root}")
 
-    target_files = list(root.rglob("chives-*.js"))
+    target_files = [p for p in root.rglob("chives-*.js") if ".venv" not in p.parts]
 
     if not target_files:
         print("No 'chives-*.js' files found in the current directory.")

tests/python/test_javascript.py (3512 → 3998)

diff --git a/tests/python/test_javascript.py b/tests/python/test_javascript.py
index a92266b..1c14515 100644
--- a/tests/python/test_javascript.py
+++ b/tests/python/test_javascript.py
@@ -104,3 +104,17 @@ class TestUpdateJsComponents:
 
         javascript.update_js_components(root=tmp_path, js_assets=JS_DIR)
         assert (tmp_path / "static/chives-image.js").stat().st_mtime == mtime
+
+    def test_ignores_js_file_in_venv(self, tmp_path: Path) -> None:
+        """
+        If there's a JS file in a virtualenv, it's left as-is.
+        """
+        venv_path = tmp_path / ".venv"
+        venv_path.mkdir()
+
+        js = "// javascript/chives-image.js\n// chives version: 1\n"
+        (venv_path / "chives-image.js").write_text(js)
+
+        javascript.update_js_components(root=tmp_path, js_assets=JS_DIR)
+
+        assert (venv_path / "chives-image.js").read_text() == js