You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a script that uses prompts it can not accept a stdin redirection from a file. The file will be read but prompts ignores the new lines so that the whole file is used as the input to the first prompt only.
Steps to reproduce the behavior:
Create a script that accepts multiple text inputs (prompts-test.js)
Create a text file with answers to the prompt questions (project.txt)
My test project
A test project using prompts
Run the script with redirection from the text file
node prompts-test.js < project.txt
Expected behavior
The script should accept each line from the text file as an answer to the single prompt and then show the response as an object on the console.
✔ What is your project name? … My test project
✔ What is your project description? … A test project using prompts
User entered: {
name: 'My test project',
description: 'A test project using prompts'
}
The actual result is that the script does not finish, does not show the console message, and does not trigger the catch exception function.
node prompts-test.js < project.txt
✔ What is your project name? … My test projectA test project using prompts
? What is your project description? › My project description%
System
OS: Linux 6.8.0-53-generic x86_64
Terminal: zsh 5.9
Node version: v22.13.0
Additional context
The redirection to accept input from text files would be a great benefit to automate initializing projects using scripts and without waiting for user input.
The text was updated successfully, but these errors were encountered:
Describe the bug
When running a script that uses prompts it can not accept a stdin redirection from a file. The file will be read but prompts ignores the new lines so that the whole file is used as the input to the first prompt only.
Steps to reproduce the behavior:
Expected behavior
The script should accept each line from the text file as an answer to the single prompt and then show the response as an object on the console.
The actual result is that the script does not finish, does not show the console message, and does not trigger the catch exception function.
System
Additional context
The redirection to accept input from text files would be a great benefit to automate initializing projects using scripts and without waiting for user input.
The text was updated successfully, but these errors were encountered: