tt-help-cli-ycl 1.4.67 → 1.4.68

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.67",
3
+ "version": "1.4.68",
4
4
  "description": "TikTok user & video data scraper - extract ttSeller, verified, locationCreated from HTML source",
5
5
  "type": "module",
6
6
  "bin": {
@@ -112,10 +112,17 @@ export class ProcessManager extends EventEmitter {
112
112
  command = parts[0] || command;
113
113
  args = parts.slice(1);
114
114
  }
115
- child = spawn(command, args, {
116
- stdio: ["ignore", "pipe", "pipe"],
117
- detached: false,
118
- });
115
+ // Windows .cmd 文件必须 shell:true,macOS/Linux 直接 spawn
116
+ child = IS_WIN
117
+ ? spawn(command, args, {
118
+ stdio: ["ignore", "pipe", "pipe"],
119
+ detached: false,
120
+ shell: true,
121
+ })
122
+ : spawn(command, args, {
123
+ stdio: ["ignore", "pipe", "pipe"],
124
+ detached: false,
125
+ });
119
126
  } catch (e) {
120
127
  console.error(`[watchdog] 启动命令 ${id} 失败: ${e.message}`);
121
128
  this.processes.set(id, {
@@ -203,16 +210,23 @@ export class ProcessManager extends EventEmitter {
203
210
 
204
211
  if (info.child) {
205
212
  try {
206
- // 尝试优雅终止
207
- info.child.kill("SIGTERM");
208
- // 2 秒后强制 kill
209
- setTimeout(() => {
210
- try {
211
- if (info.child && info.child.exitCode === null) {
212
- info.child.kill("SIGKILL");
213
- }
214
- } catch {}
215
- }, 2000);
213
+ if (IS_WIN) {
214
+ // Windows: shell:true 产生 cmd.exe 中间层,必须杀整个进程树
215
+ execSync(`taskkill /PID ${info.child.pid} /T /F`, {
216
+ stdio: ["ignore", "ignore", "ignore"],
217
+ timeout: 5000,
218
+ });
219
+ } else {
220
+ // macOS/Linux: 优雅终止,2 秒后强制 kill
221
+ info.child.kill("SIGTERM");
222
+ setTimeout(() => {
223
+ try {
224
+ if (info.child && info.child.exitCode === null) {
225
+ info.child.kill("SIGKILL");
226
+ }
227
+ } catch {}
228
+ }, 2000);
229
+ }
216
230
  } catch (e) {
217
231
  console.error(`[watchdog] 停止命令 ${cmdId} 失败: ${e.message}`);
218
232
  }