Skip to content

CLI accepts invalid increment specifiers with -i/--increment and treats them as 'patch' #108

Open

Description

@mklement0

E.g.:

semver -i nonesuch 1.0.0

outputs 1.0.1 and sets exit code to 0; i.e., it acts as if patch (or no argument) had been specified.

Activity

  1. changed the title [-]CLI accepts invalid increment specifiers with -i/--increment and treats them as [/-] [+]CLI accepts invalid increment specifiers with -i/--increment and treats them as 'patch'[/+] on Oct 23, 2014
  2. lukekarrys commented on Apr 10, 2022

    @lukekarrys
    Contributor

    This is working by design. The default value of -i is patch and invalid versions are filtered out of the input.

  3. mklement0 commented on Apr 28, 2022

    @mklement0
    Author

    Quietly accepting invalid input is problematic.

    Another way of putting it: if this is by design, please reconsider the design.

    Consider reporting an error if an invalid -i argument is specified.

  4. lukekarrys commented on Jun 9, 2022

    @lukekarrys
    Contributor

    @mklement0 Thanks for the feedback. I closed this issue as a first pass through this repo, so maybe "by design" was the wrong choice of words. The code makes it clear that any invalid values passed to -i are ignored but I agree that erroring is a good idea.

    For this project I believe in a very cautious approach to versioning, so I think this would be a breaking change so I'm going to tag it as such. I don't have any immediate plans to release a major version but surfacing this as a breaking change will help to batch this in when it's time.

  5. added this to the v8 milestone on Oct 31, 2022
  6. pjohnmeyer commented on May 3, 2026

    @pjohnmeyer
    Contributor

    @lukekarrys would it be acceptable in the current v7 to add a console.warn about what is happening, and that this behavior might go away in a future version? This preserves the current behavior (including the ability to redirect or pipe the output) whilst still explaining what is happening.

  7. pjohnmeyer commented on May 10, 2026

    @pjohnmeyer
    Contributor

    @owlstronaut are you sure we want this closed? The changes I made in #859 are only a stepping stone to the v8 changes being tracked.

  8. owlstronaut commented on May 11, 2026

    @owlstronaut

    @owlstronaut are you sure we want this closed? The changes I made in #859 are only a stepping stone to the v8 changes being tracked.

    oh thanks :) things are hectic 😆

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    semver:majorbackwards-incompatible breaking changes

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions