Skip to content

CLI option --version is not working without tty attached #37

@thomasleplus

Description

@thomasleplus

Hi,

This is not a big deal but I noticed that when I run npx jwt-cli --version in a docker container not attached to a terminal, the option is ignored and jwt-cli tries to read a JWT from STDIN instead.

$ docker run --rm node npx --yes jwt-cli --version 
/root/.npm/_npx/0badcb491528d04f/node_modules/fast-jwt/src/decoder.js:18
    throw new TokenError(TokenError.codes.malformed, 'The token is malformed.')
          ^

TokenError: The token is malformed.
    at decode (/root/.npm/_npx/0badcb491528d04f/node_modules/fast-jwt/src/decoder.js:18:11)
    at decodeToken (/root/.npm/_npx/0badcb491528d04f/node_modules/jwt-cli/src/jwt.js:10:22)
    at /root/.npm/_npx/0badcb491528d04f/node_modules/jwt-cli/index.js:23:24
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5) {
  code: 'FAST_JWT_MALFORMED'
}

Node.js v25.1.0

It works if I add -it to the docker run command:

$ docker run --rm -it node npx --yes [email protected] --version 
2.0.0

It also works with version 1.3.3:

$ docker run --rm node npx --yes [email protected] --version 
jwt-cli - JSON Web Token parser [version 1.3.3]

Usage: jwt <encoded token> --secret=<signing secret>

ℹ Documentation: https://www.npmjs.com/package/jwt-cli
⚠ Issue tracker: https://github.com/troyharvey/jwt-cli/issues

I noticed because when I run my CI/CD pipeline in debug mode, I am printing the version of all the tools that I use. I'll just skip jwt-cli for now but I thought I'd let you know.

Cheers,

Tom

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions