@cloud411716/fancy-webnovel 0.1.92 → 0.1.94

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": "@cloud411716/fancy-webnovel",
3
- "version": "0.1.92",
3
+ "version": "0.1.94",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -169,10 +169,9 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
169
169
  cwd: process.cwd(),
170
170
  });
171
171
  const installOut = [];
172
- let sudoPrompted = false;
173
172
 
174
173
  installProc.stdout.on('data', d => { installOut.push(d.toString()); });
175
- installProc.stderr.on('data', d => { installOut.push(d.toString()); });
174
+ // stderr 不进 installOut(sudo 提示等交互信息不要混入最终报告)
176
175
 
177
176
  // 注册 CTRL+C 取消处理:kill 安装进程
178
177
  const stopCancel = onUserCancel(session, () => {
@@ -180,27 +179,30 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
180
179
  installStop();
181
180
  });
182
181
 
182
+ let sudoDialogPromise = null;
183
183
  // 检测 sudo 密码提示
184
184
  installProc.stderr.on('data', async (d) => {
185
- if (sudoPrompted) return;
185
+ if (sudoDialogPromise) return;
186
186
  const text = d.toString();
187
187
  if (/password|密码|sudo/i.test(text)) {
188
- sudoPrompted = true;
189
- installProc.pause?.(); // 暂停输出,防止刷屏
190
- const pwdResult = await ctx.userQuestions.ask({
188
+ sudoDialogPromise = ctx.userQuestions.ask({
191
189
  questions: [{
192
190
  question: '🔐 安装过程需要 sudo 权限,请输入密码:',
193
191
  hideCustomInput: false,
194
192
  }],
195
- });
196
- const pwd = pwdResult.answers[0]?.custom ?? '';
197
- installProc.stdin?.write(pwd + '\n');
198
- installProc.resume?.(); // 恢复输出
193
+ }).then(async (pwdResult) => {
194
+ const pwd = pwdResult.answers[0]?.custom ?? '';
195
+ installProc.stdin?.write(pwd + '\n');
196
+ }).catch(() => {});
199
197
  }
200
198
  });
201
199
 
202
200
  return new Promise((resolve) => {
203
201
  installProc.on('close', async (code) => {
202
+ // 如果弹过 sudo 框,等弹框完成后再处理结果
203
+ if (sudoDialogPromise) {
204
+ await sudoDialogPromise.catch(() => {});
205
+ }
204
206
  stopCancel(); // 移除取消监听
205
207
  installStop();
206
208
  if (code === 0) {