Skip to content

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

Description

@PAMulligan

Summary

Three InDesign pipeline entry points document - as the "read from stdin"
argument (and their loadIr() helpers are written to handle it), but their
argument-parsing loops reject - as an unknown flag. The advertised stdin form
therefore fails with Unknown argument: - (exit 2). Stdin is still reachable by
omitting the positional argument, so the capability isn't lost — only the
documented - form is broken.

Found while building the new flavian-ingest stage in #146, which handles -
correctly and serves as the reference fix.

Affected entry points

Entry point Rejects - at Dead stdin branch
flavian-generate-theme packages/pipeline/bin/generate-theme.mjs:68 :94
flavian-map-tokens packages/pipeline/bin/map-tokens.mjs:60 :80
flavian pipeline indesign bin/flavian.mjs:80 :155

Each one advertises -:

  • generate-theme / map-tokens usage string: <ir.json | doc.idml | doc.pdf | ->
  • bin/flavian.mjs:86: an input is required (an .idml/.pdf file, an IR JSON, or - for stdin)

flavian-parse-idml and flavian-parse-pdf are not affected — they take a
file path only and intentionally offer no stdin mode.

Reproduction

node tests/fixtures/indesign/emit.mjs ./tmp-fix
node packages/pipeline/bin/ingest.mjs ./tmp-fix/brochure.idml --quiet \
  | node packages/pipeline/bin/generate-theme.mjs - --out-dir ./tmp-theme
# → Unknown argument: -    (exit 2)
  • Expected: - is accepted; the IR JSON is read from stdin.
  • Actual: Unknown argument: -, usage printed, exit 2.
  • Workaround: drop the - (the bins fall back to stdin when no positional is given).

Root cause

The positional-capture guard is !arg.startsWith('-'), and '-'.startsWith('-')
is true, so a bare - is never stored as the input path and falls through to
the unknown-argument branch.

Proposed fix

Treat a bare - as the stdin sentinel before the dash check — exactly what the
merged flavian-ingest bin already does at packages/pipeline/bin/ingest.mjs:53:

// before
if (!inputPath && !arg.startsWith('-')) { inputPath = arg; }
// after — a bare "-" is the explicit stdin sentinel
if (!inputPath && (arg === '-' || !arg.startsWith('-'))) { inputPath = arg; }

Apply the equivalent change in all three entry points. The downstream loadIr()
helpers already special-case inputPath === '-', so no other changes are needed.

Acceptance criteria

  • flavian-generate-theme -, flavian-map-tokens -, and flavian pipeline indesign - read the IR from stdin instead of erroring.
  • Regression coverage that piping into each entry point via - succeeds (mirror the ingest stdin path).
  • Usage/help strings stay consistent (they already advertise -; no doc change expected).
  • pnpm --filter @flavian/pipeline test, the InDesign smoke test, and the fixture tests stay green.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomersjavascriptPull requests that update javascript codepipelineFigma/Canva-to-WordPress conversion pipeline

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    In Progress

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions