Brozy123 commited on
Commit
7d1ef26
·
verified ·
1 Parent(s): 3e14013

Create postinstall.js

Browse files
Files changed (1) hide show
  1. postinstall.js +18 -0
postinstall.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // postinstall.js - Ensures native modules compile correctly on Linux/HF
2
+ const { execSync } = require("child_process");
3
+ const os = require("os");
4
+
5
+ console.log("[INSTALL] Checking environment...");
6
+
7
+ // If running on Linux (like HF Spaces), ensure build tools are conceptually ready
8
+ // Note: HF Spaces usually has build-tools installed, but this is a safe guard.
9
+ if (os.platform() === 'linux') {
10
+ console.log("[INSTALL] Linux environment detected. Ensuring native modules are ready...");
11
+ try {
12
+ // Rebuild better-sqlite3 if needed
13
+ execSync("npm rebuild better-sqlite3", { stdio: "inherit" });
14
+ console.log("[INSTALL] Native modules rebuilt successfully.");
15
+ } catch (e) {
16
+ console.warn("[INSTALL] Warning: Could not rebuild native modules. If the bot fails, ensure 'build-essential' is installed on the host.");
17
+ }
18
+ }