Function inc

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

    Parameters

    • version: string

      The version to increment

    • release: ReleaseType | "release"

      The release type to use, could be "major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease", 'release'

    • OptionaloptionsOrLoose: boolean | Options

      An options object { loose } (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings this param can be omitted, making identifier and identifierBase the third and the fourth params respectively

    • Optionalidentifier: string

      The identifier to use for prerelease versions

    • OptionalidentifierBase: false | IdentifierBase

      The base to use for the identifier, could be '0' or '1'

    Returns null | string

    The incremented version, or null if it's not valid

    inc('1.2.3', 'minor') // '1.3.0'
    inc('1.2.3', 'prerelease') // '1.2.4-0'
    inc('1.2', 'minor') // null
  • Return the version incremented by the release type (major, premajor, minor, preminor, patch, prepatch, or prerelease), or null if it's not valid.

    Parameters

    • version: string

      The version to increment

    • release: ReleaseType | "release"

      The release type to use, could be "major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease", 'release'

    • Optionalidentifier: string

      The identifier to use for prerelease versions

    • OptionalidentifierBase: false | IdentifierBase

      The base to use for the identifier, could be '0' or '1'

    Returns null | string

    The incremented version, or null if it's not valid

    inc('1.2.3', 'minor') // '1.3.0'
    inc('1.2.3', 'prerelease') // '1.2.4-0'
    inc('1.2', 'minor') // null