Run pa11y-ci in cross-platform manner (works on Windows)

This commit is contained in:
Micah Jerome Ellison 2022-08-21 13:40:22 -07:00
parent 98ea848151
commit 82e9074bbe
2 changed files with 7 additions and 1 deletions

View file

@ -87,7 +87,7 @@ docs-check = [
{script = "tasks:output_file('sitemap.xml')"},
{script = "tasks:generate_pa11y_config_from_sitemap"},
{script = "tasks:output_file('config.json')"},
{cmd = "npx pa11y-ci -c config.json"},
{script = "tasks:run_shell('npx pa11y-ci -c config.json')"},
{script = "tasks:delete_files(['sitemap.xml', 'config.json'])"},
]
docs-run = [

View file

@ -4,6 +4,7 @@
import json
import os
import pathlib
import subprocess
import requests
import xmltodict
@ -18,6 +19,11 @@ def delete_files(files):
pathlib.Path(file).unlink(missing_ok=True)
def run_shell(command):
# Required to run NPM commands in Windows and *nix
subprocess.call(command, shell=True)
def generate_sitemap():
sitemap = requests.get(f"{DOCS_URL}/{SITEMAP_FILENAME}")
with open(SITEMAP_FILENAME, "wb") as f: