node-mac-recorder 1.0.1 ā 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install.js +71 -0
- package/package.json +1 -1
package/install.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const { spawn } = require("child_process");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
console.log("šØ Building native macOS recorder module...\n");
|
|
6
|
+
|
|
7
|
+
// Check if we're on macOS
|
|
8
|
+
if (process.platform !== "darwin") {
|
|
9
|
+
console.error("ā This package only works on macOS");
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Check if Xcode Command Line Tools are installed
|
|
14
|
+
console.log("š Checking Xcode Command Line Tools...");
|
|
15
|
+
const xcodebuild = spawn("xcode-select", ["--print-path"], { stdio: "pipe" });
|
|
16
|
+
|
|
17
|
+
xcodebuild.on("close", (code) => {
|
|
18
|
+
if (code !== 0) {
|
|
19
|
+
console.error("ā Xcode Command Line Tools not found!");
|
|
20
|
+
console.log("š¦ Please install with: xcode-select --install");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
console.log("ā
Xcode Command Line Tools found");
|
|
25
|
+
buildNativeModule();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
function buildNativeModule() {
|
|
29
|
+
console.log("\nšļø Building native module...");
|
|
30
|
+
|
|
31
|
+
// Run node-gyp rebuild
|
|
32
|
+
const nodeGyp = spawn("node-gyp", ["rebuild"], {
|
|
33
|
+
stdio: "inherit",
|
|
34
|
+
env: { ...process.env, npm_config_build_from_source: "true" },
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
nodeGyp.on("close", (code) => {
|
|
38
|
+
if (code === 0) {
|
|
39
|
+
console.log("\nā
Native module built successfully!");
|
|
40
|
+
console.log("š node-mac-recorder is ready to use");
|
|
41
|
+
|
|
42
|
+
// Check if build output exists
|
|
43
|
+
const buildPath = path.join(
|
|
44
|
+
__dirname,
|
|
45
|
+
"build",
|
|
46
|
+
"Release",
|
|
47
|
+
"mac_recorder.node"
|
|
48
|
+
);
|
|
49
|
+
if (fs.existsSync(buildPath)) {
|
|
50
|
+
console.log("š Native module location:", buildPath);
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
console.error("\nā Build failed with code:", code);
|
|
54
|
+
console.log("\nš§ Troubleshooting:");
|
|
55
|
+
console.log(
|
|
56
|
+
"1. Make sure Xcode Command Line Tools are installed: xcode-select --install"
|
|
57
|
+
);
|
|
58
|
+
console.log("2. Check Node.js version (requires 14.0.0+)");
|
|
59
|
+
console.log("3. Try: npm run clean && npm run build");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
nodeGyp.on("error", (error) => {
|
|
65
|
+
console.error("\nā Build error:", error.message);
|
|
66
|
+
console.log(
|
|
67
|
+
"\nš¦ Make sure node-gyp is installed: npm install -g node-gyp"
|
|
68
|
+
);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
});
|
|
71
|
+
}
|