From 82e9074bbee4f7e8c65224ae666e14811f390739 Mon Sep 17 00:00:00 2001 From: Micah Jerome Ellison Date: Sun, 21 Aug 2022 13:40:22 -0700 Subject: [PATCH] Run pa11y-ci in cross-platform manner (works on Windows) --- pyproject.toml | 2 +- tasks.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c0d91650..773f40f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = [ diff --git a/tasks.py b/tasks.py index 453c2334..0fd966bd 100644 --- a/tasks.py +++ b/tasks.py @@ -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: