tt-help-cli-ycl 1.4.63 → 1.4.64

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-help-cli-ycl",
3
- "version": "1.4.63",
3
+ "version": "1.4.64",
4
4
  "description": "TikTok user & video data scraper - extract ttSeller, verified, locationCreated from HTML source",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,7 +18,7 @@ const IS_WIN = process.platform === "win32";
18
18
  function getProcessStats(pid) {
19
19
  try {
20
20
  const cmd = IS_WIN
21
- ? `tasklist /FI "PID eq ${pid}" /FO CSV /NH`
21
+ ? `powershell -NoProfile -Command "(Get-Process -Id ${pid} -ErrorAction SilentlyContinue).WorkingSet64"`
22
22
  : `ps -p ${pid} -o rss=,etime=`;
23
23
  const stdout = execSync(cmd, {
24
24
  encoding: "utf-8",
@@ -28,13 +28,13 @@ function getProcessStats(pid) {
28
28
  if (!stdout) return null;
29
29
 
30
30
  if (IS_WIN) {
31
- // tasklist CSV: "name.exe","pid","session","session#","mem usage"
32
- const cols = stdout.split(",");
33
- const memStr = (cols[4] || "").replace(/[^0-9.]/g, "");
34
- const memKB = parseInt(memStr, 10);
31
+ // PowerShell 返回字节数,运行时长从内部 startTime 计算
32
+ const memBytes = parseInt(stdout, 10);
35
33
  return {
36
- memoryMB: isNaN(memKB) ? 0 : Math.round((memKB / 1024) * 10) / 10,
37
- elapsed: "?",
34
+ memoryMB: isNaN(memBytes)
35
+ ? 0
36
+ : Math.round((memBytes / 1048576) * 10) / 10,
37
+ elapsed: null,
38
38
  };
39
39
  }
40
40
 
@@ -218,7 +218,21 @@ export class ProcessManager extends EventEmitter {
218
218
  : "error",
219
219
  memoryMB: stats?.memoryMB ?? 0,
220
220
  uptimeSeconds,
221
- uptimeDisplay: stats?.elapsed || `${uptimeSeconds}s`,
221
+ uptimeDisplay:
222
+ stats?.elapsed ||
223
+ (function (s) {
224
+ var m = Math.floor(s / 60);
225
+ var h = Math.floor(m / 60);
226
+ m = m % 60;
227
+ s = s % 60;
228
+ return h > 0
229
+ ? h +
230
+ ":" +
231
+ String(m).padStart(2, "0") +
232
+ ":" +
233
+ String(s).padStart(2, "0")
234
+ : m + ":" + String(s).padStart(2, "0");
235
+ })(uptimeSeconds),
222
236
  restartCount: info.restartCount,
223
237
  error: info.spawnError || null,
224
238
  });