@cloud411716/fancy-webnovel 0.1.92 → 0.1.93
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 +1 -1
- package/plugins/fancy-scan/index.js +11 -9
package/package.json
CHANGED
|
@@ -169,7 +169,6 @@ 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
174
|
installProc.stderr.on('data', d => { installOut.push(d.toString()); });
|
|
@@ -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 (
|
|
185
|
+
if (sudoDialogPromise) return;
|
|
186
186
|
const text = d.toString();
|
|
187
187
|
if (/password|密码|sudo/i.test(text)) {
|
|
188
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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) {
|