Skip to content

Commit

Permalink
fix(resolve-version): sort versions before retrieving latest (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
acburdine authored May 29, 2019
1 parent f479cf1 commit 8a17c8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils/resolve-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = function resolveVersion(version, activeVersion, v1 = false, for
}

return packageInfo('ghost', {allVersions: true}).then((result) => {
const versions = Object.keys(result.versions).filter(v => semver.satisfies(v, comparator));
const versions = Object.keys(result.versions).filter(v => semver.satisfies(v, comparator)).sort(semver.compare);

if (!versions.length) {
return Promise.reject(new errors.CliError({
Expand Down
6 changes: 6 additions & 0 deletions test/unit/utils/resolve-version-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ describe('Unit: resolveVersion', function () {
expect(version).to.equal('1.52.37');
});
});

it('resolves with latest version if 1.x release is newer than latest 2.x', async function () {
const resolveVersion = stub(['1.0.0', '1.0.1', '2.0.0', '2.0.1', '1.0.2']);
const version = await resolveVersion();
expect(version).to.equal('2.0.1');
});
});

describe('with existing version', function () {
Expand Down

0 comments on commit 8a17c8b

Please sign in to comment.