fix(pipeline): treat bare "-" as stdin sentinel in generate-theme, map-tokens, and flavian indesign#149
Conversation
…p-tokens, and flavian indesign
The positional-capture guard `!arg.startsWith('-')` incorrectly rejected
a bare `-` because `'-'.startsWith('-')` is true. Add `arg === '-'` as
an explicit early condition so the stdin sentinel is captured before the
dash check, matching the pattern already used in flavian-ingest (ref PMDevSolutions#146).
Affected: packages/pipeline/bin/generate-theme.mjs:68
packages/pipeline/bin/map-tokens.mjs:60
bin/flavian.mjs:80
Fixes PMDevSolutions#148
|
Thanks for this, @circuito-suman — and welcome! 🎉 Lovely first contribution. I verified it locally and it does exactly what it should:
One bit of housekeeping: your branch is a few commits behind |
|
Thanks for this, and nice catch. You traced it to the exact line and mirrored the pattern we already use in ingest.mjs, which is exactly the right fix. The regression test that spawns each CLI and pipes to stdin is a really welcome addition too. Merged and shipped. Separately, I write a small technical newsletter about the real engineering behind these frameworks, and I'd love to feature this fix as a teaching example of the bare-dash stdin gotcha. Would you be comfortable with that? And if so, how would you like to be credited: your GitHub handle, a name, a link, or not credited at all? Totally fine either way, I just won't mention you without your okay. Thanks again for the contribution, and I hope to see more from you. |
|
Thank you for the kind words and for merging so quickly! Really glad the fix and tests were useful. Please feel free to feature it in your newsletter. I'd be happy for it to serve as a useful teaching example. You can credit me as SUMAN SAHA (@circuito-suman on GitHub). Looking forward to contributing more. The codebase is clean and well-documented, which makes it easy to navigate — the fact that ingest.mjs already had the right pattern made the fix straightforward to find and mirror. Thanks again for building something worth contributing to! |
…p-tokens, and flavian indesign
The positional-capture guard
!arg.startsWith('-')incorrectly rejected a bare-because'-'.startsWith('-')is true. Addarg === '-'as an explicit early condition so the stdin sentinel is captured before the dash check, matching the pattern already used in flavian-ingest (ref #146).Affected: packages/pipeline/bin/generate-theme.mjs:68
packages/pipeline/bin/map-tokens.mjs:60
bin/flavian.mjs:80
Fixes #148
Description
Three CLI entry points advertised
-as the stdin sentinel in their usagestrings but rejected it at runtime with
Unknown argument: -(exit 2).The bug: the positional-capture guard
!arg.startsWith('-')rejects a bare-because'-'.startsWith('-')is true, so it falls through to theunknown-argument branch instead of being stored as the input path.
The fix: add
arg === '-'as an explicit early check before the dash guardin all three affected entry points, exactly mirroring the pattern already
merged in
flavian-ingest(packages/pipeline/bin/ingest.mjs:53).Regression tests added in:
packages/pipeline/tests/indesign/stdin-sentinel.test.mjs
Related Issue
Closes #148
Type of Change
Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Chore
- [ ] Breaking change
## Checklist
- [ ] PHPCS passes
- [ ] Security scan passes
- [x] Tests pass (if applicable)
- [ ] Docker environment works
- [ ] Documentation updated (if applicable)