xypriss 9.10.16 → 9.10.17
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/package.json +1 -1
- package/scripts/postinstall.js +18 -4
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { fileURLToPath } from "url";
|
|
9
9
|
import path from "path";
|
|
10
10
|
import fs from "fs";
|
|
11
|
+
import { execSync } from "child_process";
|
|
11
12
|
import { installXems } from "./install-xems.js";
|
|
12
13
|
import { installXHSC } from "./postinstall-xhsc.js";
|
|
13
14
|
|
|
@@ -82,8 +83,23 @@ async function postInstall() {
|
|
|
82
83
|
// 1. Initial gate: Check environment variable
|
|
83
84
|
if (process.env.XFPM !== "true") return false;
|
|
84
85
|
|
|
85
|
-
// 2. Robust verification
|
|
86
|
-
|
|
86
|
+
// 2. Windows Robust verification
|
|
87
|
+
if (process.platform === "win32") {
|
|
88
|
+
let pid = process.ppid;
|
|
89
|
+
for (let i = 0; i < 2; i++) {
|
|
90
|
+
const cmd = `wmic process where (processid=${pid}) get ExecutablePath,ParentProcessId /format:list`;
|
|
91
|
+
const out = execSync(cmd, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
92
|
+
if (out.toLowerCase().includes("xfpm")) return true;
|
|
93
|
+
const match = out.match(/ParentProcessId=(\d+)/);
|
|
94
|
+
if (!match) break;
|
|
95
|
+
pid = parseInt(match[1], 10);
|
|
96
|
+
}
|
|
97
|
+
return process.env.XFPM === "true";
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 3. Linux/macOS Robust verification: Check process tree via /proc
|
|
101
|
+
if (!fs.existsSync("/proc")) return true;
|
|
102
|
+
|
|
87
103
|
let currentPid = process.pid;
|
|
88
104
|
for (let i = 0; i < 3; i++) {
|
|
89
105
|
const statusPath = `/proc/${currentPid}/status`;
|
|
@@ -95,7 +111,6 @@ async function postInstall() {
|
|
|
95
111
|
|
|
96
112
|
currentPid = parseInt(ppidMatch[1], 10);
|
|
97
113
|
|
|
98
|
-
// Check executable name in /proc/[pid]/comm
|
|
99
114
|
const commPath = `/proc/${currentPid}/comm`;
|
|
100
115
|
if (fs.existsSync(commPath)) {
|
|
101
116
|
const comm = fs.readFileSync(commPath, "utf8").trim();
|
|
@@ -103,7 +118,6 @@ async function postInstall() {
|
|
|
103
118
|
}
|
|
104
119
|
}
|
|
105
120
|
} catch (e) {
|
|
106
|
-
// Fallback for non-Linux systems or permission issues
|
|
107
121
|
return process.env.XFPM === "true";
|
|
108
122
|
}
|
|
109
123
|
return false;
|