Comments (3)
If a non 'Yes' or 'no' answer is selected, the program should either throw an error that has to be handled, or it could just ask the question again (specifying that the initial input was wrong).
Good point. I seem to have seen similar interactions before.
from inquirer.js.
The code is here:
Inquirer.js/packages/inquirer/lib/prompts/confirm.js
Lines 16 to 25 in a9a0039
@rrohans Could you give more background about your scenario and your expected behavior?
@SBoudrias Maybe we can change the logic below will be better:
Object.assign(this.opt, {
filter(input) {
if (input != null && input !== '') {
if (/^y(es)?/i.test(input)) return true;
if (/^n(o)?/i.test(input)) return false;
}
return rawDefault;
},
});
Or change it to:
if (/^(y|yes)$/i.test(input)) return true;
if (/^(n|no)$/i.test(input)) return false;
from inquirer.js.
Yeah sure. I was scaffolding a new T3 app using their create t3-app cli tool when I noticed a bug in the way they accept confirm-style inputs. I created an issue with their cli tool and was told that they use Inquirer as part of their cli tool. Upon further inspection, I found that the bug is not with their cli but with inquirer itself, as you pointed out in the code above. Ideally, if a non 'Yes' or 'no' answer is selected, the program should either throw an error that has to be handled, or it could just ask the question again (specifying that the initial input was wrong).
from inquirer.js.
Related Issues (20)
- A null shows in the prompt using mqtt.js HOT 1
- inquirer.js in windows HOT 1
- Windows 💻
- feat: `transformChoice` options for checkbox HOT 5
- Typescript intellisense auto-completion is broken in Inquirer v9 HOT 2
- 'process.stdin' in nodejs is not working properly HOT 6
- Do not show the selected option again / closes automatically HOT 8
- Feature request: nested checkboxes HOT 3
- `Error [ERR_REQUIRE_ESM]: require() of ES Module` HOT 3
- Don't reject with standard error on exit signal HOT 3
- Will the engine.node filed be downgraded back to v14 in the current v9? HOT 1
- [Feature] Allow undefined as a default HOT 1
- Any way to cast the input? HOT 2
- stdout trim issue in tests HOT 3
- Support unicode for Windows HOT 3
- Making chalk an optional dep HOT 3
- npx @inquirer/demo@latest crashes on macos sonoma 14.4.1 HOT 3
- Default value for editor prompt not written to file (old API)
- Input prompt flickers while waiting for validation function HOT 1
- How to obtain the input function's input parameter type HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inquirer.js.