Skip to content

Commit

Permalink
fix(bundler): handle explicit equals replace
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jan 15, 2020
1 parent 9d6ec38 commit 9dc7b86
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/versioning/ruby/index.ts
Expand Up @@ -69,13 +69,16 @@ const minSatisfyingVersion = (versions: string[], range: string): string =>
const getNewValue = (
currentValue: string,
rangeStrategy: RangeStrategy,
_fromVersion: string,
fromVersion: string,
toVersion: string
): string => {
let result = null;
if (isVersion(currentValue)) {
return currentValue.startsWith('v') ? 'v' + toVersion : toVersion;
}
if (currentValue.replace(/^=\s*/, '') === fromVersion) {
return currentValue.replace(fromVersion, toVersion);
}
switch (rangeStrategy) {
case 'pin':
result = pin({ to: vtrim(toVersion) });
Expand Down
7 changes: 6 additions & 1 deletion test/versioning/ruby.spec.ts
Expand Up @@ -357,7 +357,7 @@ describe('semverRuby', () => {
[
['1.2.3', '1.0.3', 'pin', '1.0.3', '1.2.3'],
['v1.2.3', 'v1.0.3', 'pin', '1.0.3', '1.2.3'],
['1.2.3', '= 1.0.3', 'pin', '1.0.3', '1.2.3'],
['= 1.2.3', '= 1.0.3', 'pin', '1.0.3', '1.2.3'],
['1.2.3', '!= 1.0.3', 'pin', '1.0.4', '1.2.3'],
['1.2.3', '> 1.0.3', 'pin', '1.0.4', '1.2.3'],
['1.2.3', '< 1.0.3', 'pin', '1.0.2', '1.2.3'],
Expand Down Expand Up @@ -431,6 +431,11 @@ describe('semverRuby', () => {
semverRuby.getNewValue('~> 1', 'replace', '1.2.0', '2.0.3')
).toEqual('~> 2');
});
it('handles explicit equals', () => {
expect(
semverRuby.getNewValue('= 5.2.2', 'replace', '5.2.2', '5.2.2.1')
).toEqual('= 5.2.2.1');
});

it('returns correct version for replace strategy', () => {
[
Expand Down

0 comments on commit 9dc7b86

Please sign in to comment.