Skip to content

increment

Increments a semantic version

Available since v1.9.0

import { increment } from '@helpers4/version';
increment(version: string, type: "major" | "minor" | "patch"): string
ParameterTypeDescription
versionstringThe version to increment
type"major" | "minor" | "patch"The increment type (‘major’, ‘minor’, ‘patch’)

string — Incremented version string

Bumps the patch number while keeping major and minor.

increment('1.2.3', 'patch')
// => '1.2.4'

Bumps the minor number and resets patch to 0.

increment('1.2.3', 'minor')
// => '1.3.0'

The v prefix is preserved if present in the input.

increment('v1.0.0', 'major')
// => 'v2.0.0'

View source on GitHub