// postinstall.js - Ensures native modules compile correctly on Linux/HF const { execSync } = require("child_process"); const os = require("os"); console.log("[INSTALL] Checking environment..."); // If running on Linux (like HF Spaces), ensure build tools are conceptually ready // Note: HF Spaces usually has build-tools installed, but this is a safe guard. if (os.platform() === 'linux') { console.log("[INSTALL] Linux environment detected. Ensuring native modules are ready..."); try { // Rebuild better-sqlite3 if needed execSync("npm rebuild better-sqlite3", { stdio: "inherit" }); console.log("[INSTALL] Native modules rebuilt successfully."); } catch (e) { console.warn("[INSTALL] Warning: Could not rebuild native modules. If the bot fails, ensure 'build-essential' is installed on the host."); } }