@dsh-sup/dsh-core-linux-x64 0.1.2-BETA.6 → 0.1.2-BETA.7
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/core.cjs +20 -1
- package/package.json +1 -1
package/core.cjs
CHANGED
|
@@ -135,7 +135,7 @@ var require_version = __commonJS({
|
|
|
135
135
|
var fs2 = require("node:fs");
|
|
136
136
|
var path2 = require("node:path");
|
|
137
137
|
function guardVersion() {
|
|
138
|
-
if (true) return String("0.1.2-BETA.
|
|
138
|
+
if (true) return String("0.1.2-BETA.7");
|
|
139
139
|
try {
|
|
140
140
|
return JSON.parse(fs2.readFileSync(path2.join(__dirname, "..", "..", "package.json"), "utf8")).version || "unknown";
|
|
141
141
|
} catch {
|
|
@@ -317,6 +317,25 @@ var require_pidlookup = __commonJS({
|
|
|
317
317
|
}
|
|
318
318
|
return out;
|
|
319
319
|
}
|
|
320
|
+
if (isWindows) {
|
|
321
|
+
const ps = "Get-CimInstance Win32_Process | Select-Object ProcessId,CommandLine | ConvertTo-Json -Compress";
|
|
322
|
+
const j = ex("powershell", ["-NoProfile", "-NonInteractive", "-Command", ps], { encoding: "utf8", timeout: 8e3 }).toString();
|
|
323
|
+
let arr = [];
|
|
324
|
+
try {
|
|
325
|
+
arr = JSON.parse(j);
|
|
326
|
+
if (!Array.isArray(arr)) arr = [arr];
|
|
327
|
+
} catch {
|
|
328
|
+
}
|
|
329
|
+
for (const it of arr) {
|
|
330
|
+
if (!it || !it.ProcessId) continue;
|
|
331
|
+
const pid = Number(it.ProcessId);
|
|
332
|
+
if (!Number.isInteger(pid) || pid <= 0) continue;
|
|
333
|
+
const cmd2 = String(it.CommandLine || "");
|
|
334
|
+
if (!cmd2.includes(pattern)) continue;
|
|
335
|
+
out.push({ pid, cmdline: cmd2 });
|
|
336
|
+
}
|
|
337
|
+
return out;
|
|
338
|
+
}
|
|
320
339
|
const res = ex("pgrep", ["-af", String(pattern)], { encoding: "utf8", timeout: 3e3 }).toString();
|
|
321
340
|
for (const line of res.split(/\r?\n/)) {
|
|
322
341
|
const m = /^(\d+)\s+([\s\S]*)$/.exec(line.trim());
|