Spaces:
Sleeping
Sleeping
Download src/classes/services/Default/DefaultService/DependencyInstaller.ts from lamsaoganh/teamta: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/spaces/lamsaoganh/teamta/resolve/main/src/classes/services/Default/DefaultService/DependencyInstaller.ts
- Command line
-
hf download hf://spaces/lamsaoganh/teamta/src/classes/services/Default/DefaultService/DependencyInstaller.ts
-
curl -L -o DependencyInstaller.ts https://huggingface.co/spaces/lamsaoganh/teamta/resolve/main/src/classes/services/Default/DefaultService/DependencyInstaller.ts
1.18 kB
| import { execSync } from "child_process"; | |
| export class DependencyInstaller { | |
| /** | |
| * Cài đặt dependencies từ command string | |
| * @param command - Lệnh cài đặt, ví dụ: "npm install express axios" | |
| * @throws Error nếu cài đặt thất bại | |
| */ | |
| static install(command: string): void { | |
| if (!command || command.trim() === "") { | |
| return; // Không có gì để cài đặt | |
| } | |
| console.log(`📦 Installing dependencies: ${command}`); | |
| try { | |
| execSync(command, { | |
| stdio: "pipe", // Capture output thay vì in ra console | |
| encoding: "utf-8", | |
| timeout: 5 * 60 * 1000, // Timeout 5 phút | |
| }); | |
| console.log(`✅ Dependencies installed successfully`); | |
| } catch (error: any) { | |
| const errorMessage = error.stderr || error.stdout || error.message; | |
| console.error(`❌ Failed to install dependencies: ${errorMessage}`); | |
| throw new Error( | |
| `Failed to install dependencies with command "${command}": ${errorMessage}` | |
| ); | |
| } | |
| } | |
| } | |