@webpod/ps 0.1.3 → 0.1.4
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/target/cjs/index.cjs +10 -7
- package/target/esm/index.mjs +10 -7
package/package.json
CHANGED
package/target/cjs/index.cjs
CHANGED
|
@@ -69,13 +69,16 @@ var IS_WIN = import_node_process.default.platform === "win32";
|
|
|
69
69
|
var WMIC_INPUT = "wmic process get ProcessId,ParentProcessId,CommandLine";
|
|
70
70
|
var isBin = (f) => {
|
|
71
71
|
if (f === "") return false;
|
|
72
|
-
if (!f.includes("/")) return true;
|
|
73
|
-
if (!f.includes("\\")) return true;
|
|
72
|
+
if (!f.includes("/") && !f.includes("\\")) return true;
|
|
74
73
|
if (f.length > 3 && f[0] === '"')
|
|
75
74
|
return f[f.length - 1] === '"' ? isBin(f.slice(1, -1)) : false;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
try {
|
|
76
|
+
if (!import_node_fs.default.existsSync(f)) return false;
|
|
77
|
+
const stat = import_node_fs.default.lstatSync(f);
|
|
78
|
+
return stat.isFile() || stat.isSymbolicLink();
|
|
79
|
+
} catch (e) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
79
82
|
};
|
|
80
83
|
var lookup = (query = {}, cb = noop) => _lookup({ query, cb, sync: false });
|
|
81
84
|
var lookupSync = (query = {}, cb = noop) => _lookup({ query, cb, sync: true });
|
|
@@ -239,8 +242,8 @@ var formatOutput = (data) => data.reduce((m, d) => {
|
|
|
239
242
|
const cmd = _cmd.length === 1 ? _cmd[0].split(/\s+/) : _cmd;
|
|
240
243
|
if (pid && cmd.length > 0) {
|
|
241
244
|
const c = cmd.findIndex((_v, i) => isBin(cmd.slice(0, i).join(" ")));
|
|
242
|
-
const command = cmd.slice(0, c).join(" ");
|
|
243
|
-
const args =
|
|
245
|
+
const command = (c === -1 ? cmd : cmd.slice(0, c)).join(" ");
|
|
246
|
+
const args = c === -1 ? [] : cmd.slice(c);
|
|
244
247
|
m.push({
|
|
245
248
|
pid,
|
|
246
249
|
ppid,
|
package/target/esm/index.mjs
CHANGED
|
@@ -8,13 +8,16 @@ var IS_WIN = process.platform === "win32";
|
|
|
8
8
|
var WMIC_INPUT = "wmic process get ProcessId,ParentProcessId,CommandLine";
|
|
9
9
|
var isBin = (f) => {
|
|
10
10
|
if (f === "") return false;
|
|
11
|
-
if (!f.includes("/")) return true;
|
|
12
|
-
if (!f.includes("\\")) return true;
|
|
11
|
+
if (!f.includes("/") && !f.includes("\\")) return true;
|
|
13
12
|
if (f.length > 3 && f[0] === '"')
|
|
14
13
|
return f[f.length - 1] === '"' ? isBin(f.slice(1, -1)) : false;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
try {
|
|
15
|
+
if (!fs.existsSync(f)) return false;
|
|
16
|
+
const stat = fs.lstatSync(f);
|
|
17
|
+
return stat.isFile() || stat.isSymbolicLink();
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
18
21
|
};
|
|
19
22
|
var lookup = (query = {}, cb = noop) => _lookup({ query, cb, sync: false });
|
|
20
23
|
var lookupSync = (query = {}, cb = noop) => _lookup({ query, cb, sync: true });
|
|
@@ -175,8 +178,8 @@ var formatOutput = (data) => data.reduce((m, d) => {
|
|
|
175
178
|
const cmd = _cmd.length === 1 ? _cmd[0].split(/\s+/) : _cmd;
|
|
176
179
|
if (pid && cmd.length > 0) {
|
|
177
180
|
const c = cmd.findIndex((_v, i) => isBin(cmd.slice(0, i).join(" ")));
|
|
178
|
-
const command = cmd.slice(0, c).join(" ");
|
|
179
|
-
const args =
|
|
181
|
+
const command = (c === -1 ? cmd : cmd.slice(0, c)).join(" ");
|
|
182
|
+
const args = c === -1 ? [] : cmd.slice(c);
|
|
180
183
|
m.push({
|
|
181
184
|
pid,
|
|
182
185
|
ppid,
|