Skip to content

fix(pipeline): treat bare "-" as stdin sentinel in generate-theme, map-tokens, and flavian indesign#149

Merged
PAMulligan merged 2 commits into
PMDevSolutions:mainfrom
circuito-suman:fix/stdin-sentinel-cli
Jun 22, 2026
Merged

fix(pipeline): treat bare "-" as stdin sentinel in generate-theme, map-tokens, and flavian indesign#149
PAMulligan merged 2 commits into
PMDevSolutions:mainfrom
circuito-suman:fix/stdin-sentinel-cli

Conversation

@circuito-suman

@circuito-suman circuito-suman commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

…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 #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 usage
strings 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 the
unknown-argument branch instead of being stored as the input path.

The fix: add arg === '-' as an explicit early check before the dash guard
in 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)

…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
@PAMulligan PAMulligan added the bug Something isn't working label Jun 22, 2026
@PAMulligan PAMulligan self-assigned this Jun 22, 2026
@PAMulligan PAMulligan added pipeline Figma/Canva-to-WordPress conversion pipeline javascript Pull requests that update javascript code good first issue Good for newcomers labels Jun 22, 2026
@PAMulligan PAMulligan added this to the v2.0.0 milestone Jun 22, 2026
@PAMulligan PAMulligan self-requested a review June 22, 2026 22:56
@PAMulligan PAMulligan moved this to In Review in PMDS Open Source Roadmap Jun 22, 2026
@PAMulligan

Copy link
Copy Markdown
Collaborator

Thanks for this, @circuito-suman — and welcome! 🎉 Lovely first contribution.

I verified it locally and it does exactly what it should:

  • Reproduced the bug on all three CLIs first: generate-theme, map-tokens, and
    flavian pipeline indesign each rejected a bare - with Unknown argument: -
    (exit 2), even though their usage strings advertise -.
  • With your fix, all three accept - as the stdin sentinel and read the piped IR —
    exit 0, no more Unknown argument.
  • The change mirrors the canonical packages/pipeline/bin/ingest.mjs pattern exactly,
    and stays scoped to the positional-capture branch — a second - or any genuine
    unknown flag still correctly exits 2 (nice touch covering that in the regression
    tests 👍).
  • Full pipeline suite passes locally (126/126), including your new
    stdin-sentinel.test.mjs.

One bit of housekeeping: your branch is a few commits behind main. There are no
conflicts (none of those commits touch these files), so either give it a quick update
from main when you have a moment, or we're happy to bring it up to date at merge —
whichever's easier for you. Thanks again for the thorough fix and the test coverage!

@PAMulligan PAMulligan merged commit a8b67d5 into PMDevSolutions:main Jun 22, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in PMDS Open Source Roadmap Jun 22, 2026
@PAMulligan

Copy link
Copy Markdown
Collaborator

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.

@circuito-suman

Copy link
Copy Markdown
Contributor Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working good first issue Good for newcomers javascript Pull requests that update javascript code pipeline Figma/Canva-to-WordPress conversion pipeline

Projects

Development

Successfully merging this pull request may close these issues.

Pipeline CLIs reject the documented - stdin argument (generate-theme, map-tokens, flavian indesign)

2 participants