Skip to content

Commit

Permalink
added check for dependencyData.version nullability (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
LockedThread authored Jun 25, 2024
1 parent df4eeed commit 898f643
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/rust/src/generators/release-version/release-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,19 +424,22 @@ To fix this you will either need to add a Cargo.toml file at that location, or c
versionPrefix = ''; // we don't want to end up printing auto

if (currentVersion) {
const dependencyVersion =
typeof dependencyData === 'string'
? dependencyData
: dependencyData.version;
const prefixMatch = dependencyVersion.match(/^[~^=]/);
if (prefixMatch) {
versionPrefix = prefixMatch[0];
} else {
versionPrefix = '';
if (dependencyData.version) {
const dependencyVersion =
typeof dependencyData === 'string'
? dependencyData
: dependencyData.version;
const prefixMatch = dependencyVersion.match(/^[~^=]/);
if (prefixMatch) {
versionPrefix = prefixMatch[0];
} else {
versionPrefix = '';
}
}

// In rust the default version prefix/behavior is ^, so a ^ may have been inferred by cargo metadata via no prefix or an explicit ^.
if (versionPrefix === '^') {
// dependencyData.version is ensured to not be null here because of the versionPrefix == '^' check
if (!dependencyData.version.startsWith('^')) {
versionPrefix = '';
}
Expand Down

0 comments on commit 898f643

Please sign in to comment.