forked from aslanon/node-mac-recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.js
More file actions
71 lines (61 loc) · 1.96 KB
/
install.js
File metadata and controls
71 lines (61 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const { spawn } = require("child_process");
const fs = require("fs");
const path = require("path");
console.log("🔨 Building native macOS recorder module...\n");
// Check if we're on macOS
if (process.platform !== "darwin") {
console.error("❌ This package only works on macOS");
process.exit(1);
}
// Check if Xcode Command Line Tools are installed
console.log("🔍 Checking Xcode Command Line Tools...");
const xcodebuild = spawn("xcode-select", ["--print-path"], { stdio: "pipe" });
xcodebuild.on("close", (code) => {
if (code !== 0) {
console.error("❌ Xcode Command Line Tools not found!");
console.log("📦 Please install with: xcode-select --install");
process.exit(1);
}
console.log("✅ Xcode Command Line Tools found");
buildNativeModule();
});
function buildNativeModule() {
console.log("\n🏗️ Building native module...");
// Run node-gyp rebuild
const nodeGyp = spawn("node-gyp", ["rebuild"], {
stdio: "inherit",
env: { ...process.env, npm_config_build_from_source: "true" },
});
nodeGyp.on("close", (code) => {
if (code === 0) {
console.log("\n✅ Native module built successfully!");
console.log("🎉 node-mac-recorder is ready to use");
// Check if build output exists
const buildPath = path.join(
__dirname,
"build",
"Release",
"mac_recorder.node"
);
if (fs.existsSync(buildPath)) {
console.log("📁 Native module location:", buildPath);
}
} else {
console.error("\n❌ Build failed with code:", code);
console.log("\n🔧 Troubleshooting:");
console.log(
"1. Make sure Xcode Command Line Tools are installed: xcode-select --install"
);
console.log("2. Check Node.js version (requires 14.0.0+)");
console.log("3. Try: npm run clean && npm run build");
process.exit(1);
}
});
nodeGyp.on("error", (error) => {
console.error("\n❌ Build error:", error.message);
console.log(
"\n📦 Make sure node-gyp is installed: npm install -g node-gyp"
);
process.exit(1);
});
}