UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

41 lines (34 loc) 1.53 kB
/** * Wrapper for better-sqlite3 that uses our embedded binaries * This runs when the module is actually imported, not during installation */ const fs = require('fs'); const path = require('path'); // Detect platform const platform = process.platform; const arch = process.arch; const platformDir = `${platform}-${arch}`; // Find our prebuilt binary const ourBinaryPath = path.join(__dirname, '..', '..', 'prebuilds', platformDir, 'better-sqlite3.node'); // Check if we need to copy our binary if (fs.existsSync(ourBinaryPath)) { try { // Find better-sqlite3 in node_modules const betterSqlitePath = require.resolve('better-sqlite3'); const betterSqliteDir = path.dirname(betterSqlitePath); // Create build/Release directory const targetDir = path.join(betterSqliteDir, 'build', 'Release'); const targetPath = path.join(targetDir, 'better_sqlite3.node'); // Only copy if not already there or different size if (!fs.existsSync(targetPath) || fs.statSync(targetPath).size !== fs.statSync(ourBinaryPath).size) { console.log(`🔧 Installing prebuilt better-sqlite3 for ${platformDir}...`); fs.mkdirSync(targetDir, { recursive: true }); fs.copyFileSync(ourBinaryPath, targetPath); console.log('✅ Prebuilt binary installed!'); } } catch (error) { // Silently continue - better-sqlite3 will compile if needed } } // Now load the actual better-sqlite3 module.exports = require('/better-sqlite3-wrapper.cjs');