diff --git a/check_wcag.py b/check_wcag.py index 047c181..e648355 100644 --- a/check_wcag.py +++ b/check_wcag.py @@ -23,6 +23,7 @@ import csv import json import subprocess import sys +import shutil from pathlib import Path from typing import Dict, List, Set @@ -37,8 +38,9 @@ def run_pa11y(url: str) -> List[dict]: Returns an empty list if pa11y fails. """ try: + cmd_base = ["pa11y"] if shutil.which("pa11y") else ["npx", "pa11y"] result = subprocess.run( - ["pa11y", url, "--standard", "WCAG2AA", "--reporter", "json"], + [*cmd_base, url, "--standard", "WCAG2AA", "--reporter", "json"], capture_output=True, text=True, check=False,