Skip to main content
Glama

GonMCPtool

npmBuildTool.ts1.11 kB
import { exec } from 'child_process'; import { promisify } from 'util'; const execPromise = promisify(exec); /** * 執行npm build指令的工具類 */ export class NpmBuildTool { /** * 執行npm build指令 * @param path 要執行build的專案路徑,默認為當前路徑 * @param options 額外的npm指令選項 * @returns 包含stdout和stderr的Promise */ static async executeBuild(path: string = '.', options: string = ''): Promise<{ stdout: string; stderr: string }> { try { console.log(`執行 npm build ${options} 在路徑 ${path}`); // 構建完整指令 const command = `cd ${path} && npm run build ${options}`; // 執行指令 const { stdout, stderr } = await execPromise(command); if (stdout) { console.log('Build輸出:', stdout); } if (stderr && !stderr.includes('npm notice')) { console.error('Build錯誤:', stderr); } return { stdout, stderr }; } catch (error) { console.error('Build執行失敗:', error); throw error; } } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/GonTwVn/GonMCPtool'

If you have feedback or need assistance with the MCP directory API, please join our Discord server