@weapp-tailwindcss/hbuilderx-runner 0.1.4 → 0.1.5

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/dist/index.cjs CHANGED
@@ -132,7 +132,7 @@ async function findRunningHBuilderXCliCandidates(platform = node_process.default
132
132
  `$PSModuleAutoLoadingPreference = 'None'`,
133
133
  `[Console]::Error.WriteLine('process-discovery: querying')`,
134
134
  `$paths = [System.Collections.Generic.List[string]]::new()`,
135
- `foreach ($p in [System.Diagnostics.Process]::GetProcessesByName('HBuilderX')) { try { $paths.Add([Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($p.MainModule.FileName))) } finally { $p.Dispose() } }`,
135
+ `foreach ($p in [System.Diagnostics.Process]::GetProcessesByName('HBuilderX')) { try { $paths.Add([Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($p.MainModule.FileName))) } catch {} finally { $p.Dispose() } }`,
136
136
  `[Console]::Error.WriteLine('process-discovery: complete')`,
137
137
  `[Console]::WriteLine('WT-HBUILDERX-PROCESSES/1')`,
138
138
  `[Console]::WriteLine([string]::Join([Environment]::NewLine, $paths))`,
@@ -143,18 +143,25 @@ async function findRunningHBuilderXCliCandidates(platform = node_process.default
143
143
  "-o",
144
144
  "command="
145
145
  ];
146
- const result = (0, node_child_process.spawnSync)(command, args, {
147
- encoding: "utf8",
148
- stdio: [
149
- "ignore",
150
- "pipe",
151
- "pipe"
152
- ],
153
- windowsHide: true,
154
- timeout: 1e4,
155
- maxBuffer: 1048576
156
- });
157
- if (result.error || result.status !== 0) throw new Error(`HBuilderX 进程探测失败:${command}, exit=${result.status}, signal=${result.signal}, cwd=${node_process.default.cwd()}\n${result.error?.message ?? ""}\n${result.stderr ?? ""}\n${result.stdout ?? ""}`);
146
+ const timeout = 15e3;
147
+ const maxAttempts = platform === "win32" ? 3 : 1;
148
+ let result;
149
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
150
+ result = (0, node_child_process.spawnSync)(command, args, {
151
+ encoding: "utf8",
152
+ stdio: [
153
+ "ignore",
154
+ "pipe",
155
+ "pipe"
156
+ ],
157
+ windowsHide: true,
158
+ timeout,
159
+ maxBuffer: 1048576
160
+ });
161
+ if (!result.error && result.status === 0) break;
162
+ if (!(result.signal === "SIGTERM" || result.error?.code === "ETIMEDOUT") || attempt === maxAttempts - 1) break;
163
+ }
164
+ if (!result || result.error || result.status !== 0) throw new Error(`HBuilderX 进程探测失败:${command}, exit=${result?.status}, signal=${result?.signal}, cwd=${node_process.default.cwd()}\n${result?.error?.message ?? ""}\n${result?.stderr ?? ""}\n${result?.stdout ?? ""}`);
158
165
  let executables;
159
166
  if (platform === "win32") {
160
167
  const lines = result.stdout.replace(/^\uFEFF/, "").trim().split(/\r?\n/);
package/dist/index.mjs CHANGED
@@ -105,7 +105,7 @@ async function findRunningHBuilderXCliCandidates(platform = process.platform) {
105
105
  `$PSModuleAutoLoadingPreference = 'None'`,
106
106
  `[Console]::Error.WriteLine('process-discovery: querying')`,
107
107
  `$paths = [System.Collections.Generic.List[string]]::new()`,
108
- `foreach ($p in [System.Diagnostics.Process]::GetProcessesByName('HBuilderX')) { try { $paths.Add([Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($p.MainModule.FileName))) } finally { $p.Dispose() } }`,
108
+ `foreach ($p in [System.Diagnostics.Process]::GetProcessesByName('HBuilderX')) { try { $paths.Add([Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($p.MainModule.FileName))) } catch {} finally { $p.Dispose() } }`,
109
109
  `[Console]::Error.WriteLine('process-discovery: complete')`,
110
110
  `[Console]::WriteLine('WT-HBUILDERX-PROCESSES/1')`,
111
111
  `[Console]::WriteLine([string]::Join([Environment]::NewLine, $paths))`,
@@ -116,18 +116,25 @@ async function findRunningHBuilderXCliCandidates(platform = process.platform) {
116
116
  "-o",
117
117
  "command="
118
118
  ];
119
- const result = spawnSync(command, args, {
120
- encoding: "utf8",
121
- stdio: [
122
- "ignore",
123
- "pipe",
124
- "pipe"
125
- ],
126
- windowsHide: true,
127
- timeout: 1e4,
128
- maxBuffer: 1048576
129
- });
130
- if (result.error || result.status !== 0) throw new Error(`HBuilderX 进程探测失败:${command}, exit=${result.status}, signal=${result.signal}, cwd=${process.cwd()}\n${result.error?.message ?? ""}\n${result.stderr ?? ""}\n${result.stdout ?? ""}`);
119
+ const timeout = 15e3;
120
+ const maxAttempts = platform === "win32" ? 3 : 1;
121
+ let result;
122
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
123
+ result = spawnSync(command, args, {
124
+ encoding: "utf8",
125
+ stdio: [
126
+ "ignore",
127
+ "pipe",
128
+ "pipe"
129
+ ],
130
+ windowsHide: true,
131
+ timeout,
132
+ maxBuffer: 1048576
133
+ });
134
+ if (!result.error && result.status === 0) break;
135
+ if (!(result.signal === "SIGTERM" || result.error?.code === "ETIMEDOUT") || attempt === maxAttempts - 1) break;
136
+ }
137
+ if (!result || result.error || result.status !== 0) throw new Error(`HBuilderX 进程探测失败:${command}, exit=${result?.status}, signal=${result?.signal}, cwd=${process.cwd()}\n${result?.error?.message ?? ""}\n${result?.stderr ?? ""}\n${result?.stdout ?? ""}`);
131
138
  let executables;
132
139
  if (platform === "win32") {
133
140
  const lines = result.stdout.replace(/^\uFEFF/, "").trim().split(/\r?\n/);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/hbuilderx-runner",
3
3
  "type": "module",
4
- "version": "0.1.4",
4
+ "version": "0.1.5",
5
5
  "description": "HBuilderX runner utilities for cross-platform uni-app Tailwind CSS workflows. 跨端 uni-app Tailwind CSS 工作流的 HBuilderX 运行器工具。",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",