-
-
Notifications
You must be signed in to change notification settings - Fork 315
Closed
Description
Describe the bug
Some prompts spam terminal when redirecting stdout.
As far as I found out, some prompts include "select", "multiselect", "number", "autosuggest", and "autosuggestMultiselect".
To Reproduce
- Create a file and call
promptwith{ type: "select", stdout: process.stderr }.
const { prompt } = require("prompts");
(async () => {
const r = await prompt({
name: "spam",
type: "select",
message: "Pick one!",
stdout: process.stderr,
choices: [
{ value: "Charmander" },
{ value: "Bulbasaur" },
{ value: "Squirtle" },
{ value: "Pikachu" },
{ value: "Eevee" },
],
});
})();-
Run the script and redirect stdout to something (such as
/dev/null).

Type"number"will not output duplicately until some errors occurs.

Expected behavior
Should run properly even if stdout is redirected.
System
- OS: Ubuntu 20.04 on WSL on Windows 10 2004
- Terminal: Windows Terminal (used in the screenshots), VSCode integrated, and WSL console
- Node version: both
v8.17.0andv14.11.0
Additional context
This issue seems to be caused by clear function. It uses process.stdout.columns even if it should use process.stderr.columns. When stdout is redirected to something, process.stdout.columns will be undefined, so "clear" clears nothing.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
