Skip to content

[BUG] inc() may produce invalid semver with ReleaseType: prerelease #349

@boxcee

Description

@boxcee

What / Why

Given an identifier I want to increment a prerelease version.

Current Behavior

Given an 'invalid' identifier, inc() will produce an invalid semver.

Steps to Reproduce

const identifier = 'hotfix/410';
const incremented = inc(parse('0.0.1'), 'prerelease', identifier);
console.log(!!valid(incremented));
// => false

Expected Behavior

The documentation of inc() specifies this:

Return the version incremented by the release type (major, premajor, minor, preminor, patch, prepatch, or prerelease), or null if it's not valid

In the case above inc() is not returning null, even though the resulting version is not a valid semver. Either the documentation needs to be changed to 'or null if the ReleaseType is not valid' or inc() needs to check the validity of the semver before returning it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions