Skip to main content
Glama

MCP Serial Port Tool

by niusulong
fix-imports.js1.21 kB
const fs = require('fs'); const path = require('path'); function fixImports(dir) { const files = fs.readdirSync(dir, { withFileTypes: true }); for (const file of files) { const fullPath = path.join(dir, file.name); if (file.isDirectory()) { fixImports(fullPath); } else if (file.name.endsWith('.js') && file.name !== 'index.js' && file.name !== 'index.new.js') { let content = fs.readFileSync(fullPath, 'utf8'); // Replace @/ imports with relative paths content = content.replace(/require\("(@\/[^"]+)"\)/g, (match, importPath) => { const relativePath = importPath.replace('@/', './'); return `require("${relativePath}")`; }); // Also handle require with single quotes content = content.replace(/require\('(@\/[^']+)'\)/g, (match, importPath) => { const relativePath = importPath.replace('@/', './'); return `require('${relativePath}')`; }); fs.writeFileSync(fullPath, content); console.log(`Fixed imports in: ${fullPath}`); } } } // Fix all imports in the dist directory fixImports('./dist'); console.log('Import fixing complete!');

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/niusulong/mcp2serial'

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