Skip to content

Commit e2d6936

Browse files
committed
fix: show live output during npm commands in setup script
Stream npm output in real-time so users see progress instead of a frozen terminal. Also remove redundant npm install call since npm create astro --yes already installs dependencies.
1 parent a5bb0a2 commit e2d6936

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

setup.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,22 @@ def run_command(args: list[str], cwd: Path | None = None) -> tuple[bool, str]:
7171
return result.returncode == 0, output
7272

7373

74+
def run_command_live(args: list[str], cwd: Path | None = None) -> tuple[bool, str]:
75+
process = subprocess.Popen(
76+
args,
77+
cwd=cwd,
78+
stdout=subprocess.PIPE,
79+
stderr=subprocess.STDOUT,
80+
text=True,
81+
)
82+
output_lines = []
83+
for line in process.stdout:
84+
print(f" {line}", end="")
85+
output_lines.append(line)
86+
process.wait()
87+
return process.returncode == 0, "".join(output_lines)
88+
89+
7490
def copy_starlight_templates(docs_dir: Path, replacements: dict[str, str]) -> None:
7591
print_step("Copying template files...")
7692

@@ -104,7 +120,7 @@ def setup_starlight(replacements: dict[str, str]) -> bool:
104120
docs_dir = SCRIPT_DIR / "docs"
105121

106122
print_step("Creating Starlight documentation site...")
107-
success, output = run_command(
123+
success, output = run_command_live(
108124
["npm", "create", "astro@latest", "docs", "--", "--template", "starlight", "--no-git", "--yes"],
109125
cwd=SCRIPT_DIR,
110126
)
@@ -114,16 +130,8 @@ def setup_starlight(replacements: dict[str, str]) -> bool:
114130
return False
115131
print_success("Starlight site created")
116132

117-
print_step("Installing dependencies...")
118-
success, output = run_command(["npm", "install"], cwd=docs_dir)
119-
if not success:
120-
print_error("Failed to install dependencies")
121-
print(output)
122-
return False
123-
print_success("Dependencies installed")
124-
125133
print_step("Installing rehype-external-links...")
126-
success, output = run_command(["npm", "install", "rehype-external-links"], cwd=docs_dir)
134+
success, output = run_command_live(["npm", "install", "rehype-external-links"], cwd=docs_dir)
127135
if not success:
128136
print_error("Failed to install rehype-external-links")
129137
print(output)

0 commit comments

Comments
 (0)