Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] `text` validate function for text when value is empty with default value

未关闭
#397 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
领域
cli

调研方向

从 core/prompts/text 开始,并使用链接的 StackBlitz 示例重现空输入情况。结合两个拟议的修复方向,审查 PR #396 草案。完成的标准是:在配置了默认值的情况下按下 Enter 会使验证使用该默认值,同时保留文档中所述的文本提示行为。

由索引模型根据 Issue 内容生成。

描述

bug

Environment

  • OS: macOS
  • Node Version: 22.5.1
  • Package: @clack/promts
  • Package Version: 0.11.0

Describe the bug
When calling the text's validate function without user input but with a default value defined, it should use the default value instead of relying solely on user input.

To Reproduce

Steps to reproduce the behavior:

  1. Open repro link
  2. Run node index.js
  3. Don't type anything, just press [Enter]
  4. See behavior described on terminal

Expected behavior
Clear use case example:
Image

CLI dev creates a text step for user to enter a path as input. There's some predefined value that CLI dev established to be the default use case for most users, but still allowing for that value to be changed.
Currently, the user would have to type/copy that entire path, causing a terrible user experience.

Fix Recommendation (starting a convo)
I see 2 possible ways to fix this:

  1. Keep validate as is and add a check to the value on core/prompts/text - link to draft PR
  2. Add a second optional argument, which would be the default value to validate. That way, Devs would have another quick option when using the validate function, without adding extra checks to the core library.

My goal with this section is to start a conversation and introduce my ideas about this issue, not a way for me to impose how I think things should be.
This would be my first contribution, so I'm pretty new here. Let me know what you think and hopefully let's get this fixed!

主要语言
TypeScript
星标
8.1k
派生
218
平均合并
1 天 23 小时
30 天内合并 PR
6

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

bombshell-dev/clack 的其他 Issue

查看 bombshell-dev/clack 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。