Command hints print to stdout when output is piped

未关闭 适合新手
#2,531 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
77/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
cli

调研方向

从 packages/cli/src/lib/command.ts 开始,阅读 writeFinalization 如何处理提示和 stdout;然后检查 packages/cli/src/commands/release/propose-version.ts,找出一个会返回提示的命令。确定并实现 stdout 不是 TTY 时应如何处理提示,同时保留交互式输出的现有行为。完成标准是:通过管道传递的 propose-version 输出只包含版本号,其他返回提示的命令也表现一致。

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

描述

In human output mode, the hint a command returns is written to stdout after the result, even when stdout isn't a TTY. So sentry release propose-version prints the version and then a Detected from git HEAD line. Scripts that capture it get two lines.

  • writeFinalization in packages/cli/src/lib/command.ts writes the hint with writeFooter(stdout, hint) whenever --json isn't set. It never checks whether stdout is a TTY.
  • propose-version returns { hint: "Detected from <source>" } on every path (packages/cli/src/commands/release/propose-version.ts).
  • Generated build scripts in the sentry wizard port (getsentry/toolkit#2529) and the Sentry UI snippets (getsentry/sentry#132671) work around it with sentry release propose-version | head -n 1. The pipe hides a failing exit code, so SENTRY_RELEASE ends up empty and the next step runs anyway.
  • It applies to any command that returns a hint, not just propose-version.

Proposal (approved by @BYK): when stdout isn't a TTY, send hints to stderr, or leave them out.

via @BYK.

--

View Session [Sentry]

主要语言
TypeScript
星标
975
派生
189
平均合并
19 小时 57 分钟
30 天内合并 PR
542

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

getsentry/toolkit 的其他 Issue

查看 getsentry/toolkit 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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