- Rewrite 00-reset.css with :where()-wrapped zero-specificity rules - Fix README token docs (--asw-* was incorrect, actual tokens use bare --*) - Add watch.py (pyinotify-based auto-rebuild of dist/asw.css on src/ changes)
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Watch src/ for changes and rebuild dist/asw.css."""
|
|
|
|
import os
|
|
import subprocess
|
|
import pyinotify
|
|
|
|
WATCH_DIR = os.path.expanduser("~/projects/asw/src")
|
|
BUILD_CMD = ["npm", "run", "build"]
|
|
|
|
class RebuildHandler(pyinotify.ProcessEvent):
|
|
def process_default(self, event):
|
|
if event.name and event.name.endswith(".css"):
|
|
print(f"[watch] {event.name} changed → rebuilding...")
|
|
result = subprocess.run(BUILD_CMD, cwd=os.path.dirname(WATCH_DIR),
|
|
capture_output=True, text=True)
|
|
if result.returncode == 0:
|
|
print("[watch] Build OK")
|
|
else:
|
|
print(f"[watch] Build FAILED:\n{result.stderr}")
|
|
|
|
def main():
|
|
wm = pyinotify.WatchManager()
|
|
mask = pyinotify.IN_MODIFY | pyinotify.IN_CREATE | pyinotify.IN_DELETE
|
|
handler = RebuildHandler()
|
|
notifier = pyinotify.Notifier(wm, handler)
|
|
wm.add_watch(WATCH_DIR, mask, rec=True)
|
|
print(f"[watch] Watching {WATCH_DIR} for changes. Ctrl+C to stop.")
|
|
notifier.loop()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|