Skip to content

Commit

Permalink
fix(release): handle case of invalid specifierSource with convent commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fahslaj committed Sep 27, 2023
1 parent f78364d commit f4627ec
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/nx/src/command-line/release/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,19 @@ async function resolveSemverSpecifier(

switch (specifierSource) {
case 'conventional-commits':
const generatorOptions: { tagVersionPrefix?: string } | undefined =
releaseGroup.version.generatorOptions.currentVersionResolverMetadata;
const tagVersionPrefix = generatorOptions?.tagVersionPrefix || 'v';
const generatorOptions = releaseGroup.version.generatorOptions;

if (generatorOptions?.currentVersionResolver !== 'git-tag') {
throw new Error(
`Invalid currentVersionResolver "${generatorOptions?.currentVersionResolver}" provided. Must be "git-tag" when "specifierSource" is "conventional-commits"`
);
}

const currentVersionResolverMetadata:
| { tagVersionPrefix?: string }
| undefined = generatorOptions?.currentVersionResolverMetadata;
const tagVersionPrefix =
currentVersionResolverMetadata?.tagVersionPrefix ?? 'v';

const currentVersionTag = await getLastGitTag(`${tagVersionPrefix}*.*.*`);
const currentVersion = currentVersionTag.replace(tagVersionPrefix, '');
Expand Down

0 comments on commit f4627ec

Please sign in to comment.