terminfo.dev 1.3.0 → 1.4.0
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/index.ts +12 -0
- package/src/submit.ts +18 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -79,6 +79,18 @@ async function runProbes(): Promise<ProbeResults> {
|
|
|
79
79
|
process.stdout.write("\x1b[?1049l")
|
|
80
80
|
})
|
|
81
81
|
|
|
82
|
+
// Drain any late-arriving escape sequence responses before output
|
|
83
|
+
await new Promise<void>((resolve) => {
|
|
84
|
+
process.stdin.resume()
|
|
85
|
+
const timer = setTimeout(() => {
|
|
86
|
+
process.stdin.pause()
|
|
87
|
+
process.stdin.removeAllListeners("readable")
|
|
88
|
+
resolve()
|
|
89
|
+
}, 100)
|
|
90
|
+
process.stdin.on("readable", () => { while (process.stdin.read() !== null) {} })
|
|
91
|
+
timer.unref()
|
|
92
|
+
})
|
|
93
|
+
|
|
82
94
|
return { terminal, results, notes, responses, passed, total: ALL_PROBES.length }
|
|
83
95
|
}
|
|
84
96
|
|
package/src/submit.ts
CHANGED
|
@@ -23,7 +23,25 @@ interface SubmitData {
|
|
|
23
23
|
probeCount?: number
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/** Drain any leftover bytes from stdin (e.g., late-arriving escape sequence responses) */
|
|
27
|
+
async function drainStdin(): Promise<void> {
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
|
+
if (!process.stdin.readable) { resolve(); return }
|
|
30
|
+
process.stdin.resume()
|
|
31
|
+
const timer = setTimeout(() => {
|
|
32
|
+
process.stdin.pause()
|
|
33
|
+
process.stdin.removeAllListeners("readable")
|
|
34
|
+
resolve()
|
|
35
|
+
}, 200)
|
|
36
|
+
process.stdin.on("readable", () => {
|
|
37
|
+
while (process.stdin.read() !== null) {} // discard
|
|
38
|
+
})
|
|
39
|
+
timer.unref()
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
26
43
|
async function prompt(question: string, defaultValue?: string): Promise<string> {
|
|
44
|
+
await drainStdin()
|
|
27
45
|
const rl = createInterface({ input: process.stdin, output: process.stdout })
|
|
28
46
|
const suffix = defaultValue ? ` [${defaultValue}]` : ""
|
|
29
47
|
return new Promise((resolve) => {
|