Skip to main content
Glama
utils.js872 B
import { fileURLToPath } from 'url'; import { dirname } from 'path'; import { exec } from 'child_process'; import { promisify } from 'util'; const execAsync = promisify(exec); // 将 exec 转换为返回 Promise 的函数 export async function runCommand(cmd, cwd) { try { const stdout = await execAsync(cmd, { cwd, encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'], }); // 返回 audit 的 JSON 结果 return stdout.stdout.toString(); } catch (err) { if (err.stdout) { return err.stdout.toString(); } throw err; } } export function uniqueId() { return Math.random().toString(36).substring(2, 15) + Date.now().toString(36); } export function getFilename(importMetaUrl) { return fileURLToPath(importMetaUrl); } export function getDirname(importMetaUrl) { return dirname(getFilename(importMetaUrl)); }

Latest Blog Posts

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/Shen-zhihao/mcp-web-audit'

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