@noobdemon/noob-cli 1.0.8 → 1.0.9
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/src/repl.js +16 -3
package/package.json
CHANGED
package/src/repl.js
CHANGED
|
@@ -133,6 +133,14 @@ export async function startRepl(opts = {}) {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
// NOOB_DEBUG=1: vạch trần đường thoát thật sự (xác nhận/loại bỏ giả thuyết
|
|
137
|
+
// "event loop cạn"). 'beforeExit' nổ = loop cạn (stdin chết). 'exit' = thoát.
|
|
138
|
+
if (process.env.NOOB_DEBUG === "1") {
|
|
139
|
+
process.stderr.write(` [debug] isTTY=${process.stdin.isTTY} platform=${process.platform} node=${process.version}\n`);
|
|
140
|
+
process.on("beforeExit", (code) => process.stderr.write(` [debug] beforeExit code=${code} — EVENT LOOP CẠN (stdin chết)\n`));
|
|
141
|
+
process.on("exit", (code) => process.stderr.write(` [debug] exit code=${code} closed=${closed} exiting=${exiting}\n`));
|
|
142
|
+
}
|
|
143
|
+
|
|
136
144
|
let abort = null; // active turn controller
|
|
137
145
|
let sigintArmed = false;
|
|
138
146
|
process.on("SIGINT", () => {
|
|
@@ -317,7 +325,12 @@ export async function startRepl(opts = {}) {
|
|
|
317
325
|
return;
|
|
318
326
|
}
|
|
319
327
|
abort = new AbortController();
|
|
320
|
-
|
|
328
|
+
// discardStdin:false — TỐI QUAN TRỌNG. Mặc định ora chiếm stdin (raw mode +
|
|
329
|
+
// pause) để "nuốt" input khi quay. Trên Windows nó KHÔNG khôi phục sạch khi
|
|
330
|
+
// stop → stdin chết → prompt "cho phép?" hiện ra rồi event loop cạn → CLI tự
|
|
331
|
+
// out; và Ctrl+C không thành SIGINT (phải spam mới thoát). Tắt hẳn để ora
|
|
332
|
+
// đừng đụng stdin — readline tự quản.
|
|
333
|
+
const spinner = ora({ color: "magenta", spinner: "dots", discardStdin: false });
|
|
321
334
|
const t0 = Date.now();
|
|
322
335
|
let timer = null;
|
|
323
336
|
const tick = (label) => {
|
|
@@ -419,7 +432,7 @@ export async function startRepl(opts = {}) {
|
|
|
419
432
|
}
|
|
420
433
|
}
|
|
421
434
|
|
|
422
|
-
const sp = ora({ text: c.dim(" " + t.running), color: "yellow" }).start();
|
|
435
|
+
const sp = ora({ text: c.dim(" " + t.running), color: "yellow", discardStdin: false }).start();
|
|
423
436
|
try {
|
|
424
437
|
const result = await runTool(name, input);
|
|
425
438
|
sp.stop();
|
|
@@ -556,7 +569,7 @@ export async function startRepl(opts = {}) {
|
|
|
556
569
|
|
|
557
570
|
async function showUsage() {
|
|
558
571
|
if (!config.apiKey) return console.log(c.tool(" " + t.notLoggedIn));
|
|
559
|
-
const sp = ora({ text: c.dim(" ..."), color: "magenta" }).start();
|
|
572
|
+
const sp = ora({ text: c.dim(" ..."), color: "magenta", discardStdin: false }).start();
|
|
560
573
|
try {
|
|
561
574
|
const u = await usage();
|
|
562
575
|
sp.stop();
|