ascii-character-generator
Version:
ASCII character generator using MCP protocol
36 lines (30 loc) • 892 B
JavaScript
const path = require('path');
const { spawn } = require('child_process');
// Check if running in CLI mode or server mode
const args = process.argv.slice(2);
if (args.length > 0) {
// CLI mode
const figlet = require('figlet');
const text = args.join(' ');
figlet(text, (err, result) => {
if (err) {
console.error('Something went wrong...');
console.error(err);
process.exit(1);
}
console.log(result);
});
} else {
// Server mode
const serverPath = path.join(__dirname, '..', 'server.js');
const server = spawn('node', [serverPath], { stdio: 'inherit' });
server.on('error', (err) => {
console.error('Failed to start server:', err);
process.exit(1);
});
process.on('SIGINT', () => {
server.kill('SIGINT');
process.exit();
});
}