Skip to content

Commit

Permalink
fix: incorrect condition for upgrade newer version check (react-nativ…
Browse files Browse the repository at this point in the history
  • Loading branch information
thymikee authored Jul 2, 2019
1 parent 616eaf2 commit 00b9308
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/cli/src/commands/upgrade/__tests__/upgrade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ test('errors when older version passed', async () => {
expect(logger.error).toBeCalledWith(
`Trying to upgrade from newer version "${currentVersion}" to older "${olderVersion}"`,
);
await upgrade.func(['0.57.10'], ctx, opts);
expect(logger.error).not.toBeCalledWith(
`Trying to upgrade from newer version "${currentVersion}" to older "0.57.10"`,
);
}, 60000);

test('warns when dependency upgrade version is in semver range', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/upgrade/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ const getVersionToUpgradeTo = async (argv, currentVersion, projectDir) => {
return null;
}

if (currentVersion > newVersion) {
if (semver.gt(currentVersion, newVersion)) {
logger.error(
`Trying to upgrade from newer version "${currentVersion}" to older "${newVersion}"`,
);
return null;
}
if (currentVersion === newVersion) {
if (semver.eq(currentVersion, newVersion)) {
const {
dependencies: {'react-native': version},
} = require(path.join(projectDir, 'package.json'));
Expand Down

0 comments on commit 00b9308

Please sign in to comment.