@cloud411716/fancy-webnovel 0.1.89 → 0.1.90

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.89",
3
+ "version": "0.1.90",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -165,10 +165,12 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
165
165
  const installProc = spawn('sh', ['-c',
166
166
  'npm install -g @playwright/cli --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright-cli install-browser --with-deps'
167
167
  ], {
168
- stdio: ['ignore', 'pipe', 'pipe'],
168
+ stdio: ['pipe', 'pipe', 'pipe'],
169
169
  cwd: process.cwd(),
170
170
  });
171
171
  const installOut = [];
172
+ let sudoPrompted = false;
173
+
172
174
  installProc.stdout.on('data', d => { installOut.push(d.toString()); });
173
175
  installProc.stderr.on('data', d => { installOut.push(d.toString()); });
174
176
 
@@ -178,6 +180,25 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
178
180
  installStop();
179
181
  });
180
182
 
183
+ // 检测 sudo 密码提示
184
+ installProc.stderr.on('data', async (d) => {
185
+ if (sudoPrompted) return;
186
+ const text = d.toString();
187
+ if (/password|密码|sudo/i.test(text)) {
188
+ sudoPrompted = true;
189
+ installProc.pause?.(); // 暂停输出,防止刷屏
190
+ const pwdResult = await ctx.userQuestions.ask({
191
+ questions: [{
192
+ question: '🔐 安装过程需要 sudo 权限,请输入密码:',
193
+ hideCustomInput: false,
194
+ }],
195
+ });
196
+ const pwd = pwdResult.answers[0]?.custom ?? '';
197
+ installProc.stdin?.write(pwd + '\n');
198
+ installProc.resume?.(); // 恢复输出
199
+ }
200
+ });
201
+
181
202
  return new Promise((resolve) => {
182
203
  installProc.on('close', async (code) => {
183
204
  stopCancel(); // 移除取消监听