🏷️ Formats a parsed version back into a Semantic Versioning 2.0.0 string.

Syntax

TypeScript
import { semverFormat } from '@opentf/std';

semverFormat(version: Semver): string;

Parameters

NameTypeDescription
versionSemverThe parsed version.

Returns

The version string. This is the inverse of semverParse, less the tolerated v prefix — the output is always canonical.

Examples

TypeScript
semverFormat({ major: 1, minor: 2, patch: 3, prerelease: [], build: [] })
//=> '1.2.3'

semverFormat(semverParse('v2.0.0-alpha.1+build.5'))
//=> '2.0.0-alpha.1+build.5'

Normalising a version:

TypeScript
semverFormat(semverParse('  v1.2.3  ')) //=> '1.2.3'
Last updated on
Edit this page