From 48d8f8fa63bf6e35db70ff840b6da1a51596a5a8 Mon Sep 17 00:00:00 2001 From: Charley Bodkin <1542740+charlex@users.noreply.github.com> Date: Fri, 12 Jul 2019 22:55:39 +0000 Subject: [PATCH] feat: export new RELEASE_TYPES constant Which will help library consumers better integrate semver into their apps. Possible usecases of consuming this constant: - Automatically show a dropdown of available release types that conform to the semver spec - Validate user inputs where a release type is expected --- index.js | 1 + internal/constants.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4a342c6a..86d42ac1 100644 --- a/index.js +++ b/index.js @@ -83,6 +83,7 @@ module.exports = { src: internalRe.src, tokens: internalRe.t, SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, + RELEASE_TYPES: constants.RELEASE_TYPES, compareIdentifiers: identifiers.compareIdentifiers, rcompareIdentifiers: identifiers.rcompareIdentifiers, } diff --git a/internal/constants.js b/internal/constants.js index 4f0de59b..cb2d76c2 100644 --- a/internal/constants.js +++ b/internal/constants.js @@ -9,9 +9,20 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || // Max safe segment length for coercion. const MAX_SAFE_COMPONENT_LENGTH = 16 +const RELEASE_TYPES = [ + 'major', + 'premajor', + 'minor', + 'preminor', + 'patch', + 'prepatch', + 'prerelease', +] + module.exports = { - SEMVER_SPEC_VERSION, MAX_LENGTH, - MAX_SAFE_INTEGER, MAX_SAFE_COMPONENT_LENGTH, + MAX_SAFE_INTEGER, + RELEASE_TYPES, + SEMVER_SPEC_VERSION, }