File size: 507 Bytes
3ccc46c
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import re
import subprocess
from pathlib import Path

html = Path("static_space/index.html").read_text(encoding="utf-8")
scripts = re.findall(r"<script>(.*?)</script>", html, re.DOTALL)
for i, s in enumerate(scripts):
    Path(f"/tmp/check_{i}.js").write_text(s, encoding="utf-8")
    res = subprocess.run(["node", "--check", f"/tmp/check_{i}.js"], capture_output=True, text=True)
    if res.returncode == 0:
        print("Syntax check passed!")
    else:
        print("Syntax check failed:", res.stderr)