|
4 | 4 | import re |
5 | 5 | import json |
6 | 6 | from git import Repo |
| 7 | +import logging |
7 | 8 |
|
8 | 9 | kb_file_path = './data/knowledge_base.json' |
9 | 10 |
|
@@ -32,22 +33,26 @@ def setup_repositories(): |
32 | 33 | for repo_name, repo_url in repos.items(): |
33 | 34 | clone_repository(repo_url, os.path.join(tmp_dir, repo_name)) |
34 | 35 |
|
35 | | -def run_prebuild_script(): |
36 | | - """ Run the defang-docs repo prebuild script""" |
37 | | - |
38 | | - subprocess.run( |
39 | | - ["npm", "-C", ".tmp/defang-docs", "install"], |
40 | | - check=True, |
| 36 | +def run_command(cmd): |
| 37 | + process = subprocess.Popen( |
| 38 | + cmd, |
41 | 39 | stdout=subprocess.PIPE, |
42 | | - stderr=subprocess.PIPE |
| 40 | + stderr=subprocess.PIPE, |
| 41 | + text=True, |
43 | 42 | ) |
| 43 | + for line in process.stdout: |
| 44 | + logging.info(line.rstrip()) |
| 45 | + for line in process.stderr: |
| 46 | + logging.error(line.rstrip()) |
| 47 | + process.wait() |
| 48 | + if process.returncode != 0: |
| 49 | + raise RuntimeError(f"Command {cmd} failed with return code {process.returncode}") |
44 | 50 |
|
45 | | - subprocess.run( |
46 | | - ["npm", "-C", ".tmp/defang-docs", "run", "prebuild"], |
47 | | - check=True, |
48 | | - stdout=subprocess.PIPE, |
49 | | - stderr=subprocess.PIPE |
50 | | - ) |
| 51 | +def run_prebuild_script(): |
| 52 | + """ Run the defang-docs repo prebuild script""" |
| 53 | + |
| 54 | + run_command(["npm", "-C", ".tmp/defang-docs", "--loglevel=error", "install"]) |
| 55 | + run_command(["npm", "-C", ".tmp/defang-docs", "run", "prebuild"]) |
51 | 56 |
|
52 | 57 | def parse_markdown(): |
53 | 58 | """ Parse markdown files in the current directory into JSON """ |
|
0 commit comments