correct shell handling

This commit is contained in:
Kohaku-Blueleaf
2025-10-19 20:45:50 +08:00
parent 4c04c69aa7
commit 6b1e0024d1
2 changed files with 16 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ This script:
2. Runs docker compose up -d --build
"""
import platform
import subprocess
import sys
from pathlib import Path
@@ -22,7 +23,10 @@ def run_command(cmd: list[str], cwd: Path | None = None, description: str = ""):
if cwd:
print(f" in: {cwd}")
result = subprocess.run(cmd, cwd=cwd, shell=True)
# Use shell=True on Windows (npm is npm.cmd), False on Unix
use_shell = platform.system() == "Windows"
result = subprocess.run(cmd, cwd=cwd, shell=use_shell)
if result.returncode != 0:
print(f"\n❌ Command failed with exit code {result.returncode}")
@@ -37,7 +41,7 @@ def main():
ui_dir = root_dir / "src" / "kohaku-hub-ui"
admin_dir = root_dir / "src" / "kohaku-hub-admin"
print("\n🚀 KohakuHub Deployment")
print("\nKohakuHub Deployment")
print("=" * 60)
# Step 1: Build UI
@@ -54,14 +58,14 @@ def main():
)
print("\n" + "=" * 60)
print(" KohakuHub deployed successfully!")
print("[OK] KohakuHub deployed successfully!")
print("=" * 60)
print("\n📍 Access Points:")
print("\nAccess Points:")
print(" Main UI: http://localhost:28080")
print(" Admin UI: http://localhost:28080/admin")
print(" API: http://localhost:28080/api")
print(" API Docs: http://localhost:28080/docs")
print("\n💡 Tip: View logs with: docker compose logs -f")
print("\nTip: View logs with: docker compose logs -f")
if __name__ == "__main__":

View File

@@ -7,6 +7,7 @@ This script:
3. Formats backend Python code
"""
import platform
import subprocess
import sys
from pathlib import Path
@@ -23,7 +24,10 @@ def run_command(cmd: list[str], cwd: Path | None = None, description: str = ""):
if cwd:
print(f" in: {cwd}")
result = subprocess.run(cmd, cwd=cwd, shell=True)
# Use shell=True on Windows (npm is npm.cmd), False on Unix
use_shell = platform.system() == "Windows"
result = subprocess.run(cmd, cwd=cwd, shell=use_shell)
if result.returncode != 0:
print(f"\n❌ Command failed with exit code {result.returncode}")
@@ -38,7 +42,7 @@ def main():
ui_dir = root_dir / "src" / "kohaku-hub-ui"
admin_dir = root_dir / "src" / "kohaku-hub-admin"
print("\n🎨 KohakuHub Code Formatter")
print("\nKohakuHub Code Formatter")
print("=" * 60)
# Step 1: Build UI (generates router/component definitions)
@@ -67,7 +71,7 @@ def main():
run_command(["black", "."], cwd=root_dir, description="Formatting Python code")
print("\n" + "=" * 60)
print(" All code formatted successfully!")
print("[OK] All code formatted successfully!")
print("=" * 60)