Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Commit 29fb12a

Browse files
alexomanieNargonath
authored andcommitted
fix: version comparison to work with react-script version 3.0.0
the problem was that major, minor and patch where not checked independently. So the next valid version for v3 would have been v 3.1.2
1 parent 25c413f commit 29fb12a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

scripts/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ const {
1212
} = require('../utils/cliHandler');
1313
const { getReactScriptsVersion, isEjected } = require('../utils');
1414

15-
const { major, minor, patch } = getReactScriptsVersion(reactScriptsVersion);
15+
const { major, minor, patch, concatenatedVersion } = getReactScriptsVersion(reactScriptsVersion);
1616

1717
const paths = isEjected ? importCwd('./config/paths') : importCwd('react-scripts/config/paths');
1818
const webpack = importCwd('webpack');
1919

2020
const config =
21-
major >= 2 && minor >= 1 && patch >= 2
21+
Number(concatenatedVersion) >= 212
2222
? (isEjected
2323
? importCwd('./config/webpack.config')
2424
: importCwd('react-scripts/config/webpack.config'))('development')
2525
: isEjected
26-
? importCwd('./config/webpack.config.dev')
27-
: importCwd('react-scripts/config/webpack.config.dev');
26+
? importCwd('./config/webpack.config.dev')
27+
: importCwd('react-scripts/config/webpack.config.dev');
2828

2929
const HtmlWebpackPlugin = importCwd('html-webpack-plugin');
3030
const InterpolateHtmlPlugin = importCwd('react-dev-utils/InterpolateHtmlPlugin');
@@ -99,8 +99,7 @@ spinner.start('Clear destination folder');
9999

100100
let inProgress = false;
101101

102-
fs
103-
.emptyDir(paths.appBuild)
102+
fs.emptyDir(paths.appBuild)
104103
.then(() => {
105104
spinner.succeed();
106105

utils/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const DEFAULT_VERSION = {
99
major: 2,
1010
minor: 1,
1111
patch: 2,
12+
concatenatedVersion: '212',
1213
};
1314

1415
exports.isEjected = fs.pathExistsSync(path.join(process.cwd(), 'config/paths.js'));
@@ -19,6 +20,9 @@ exports.getReactScriptsVersion = function getReactScriptsVersion(cliVersion) {
1920
major: Number(semver.major(cliVersion)),
2021
minor: Number(semver.minor(cliVersion)),
2122
patch: Number(semver.patch(cliVersion)),
23+
concatenatedVersion: `${semver.major(cliVersion)}${semver.minor(cliVersion)}${semver.patch(
24+
cliVersion
25+
)}`,
2226
};
2327
return versions;
2428
}
@@ -33,6 +37,7 @@ exports.getReactScriptsVersion = function getReactScriptsVersion(cliVersion) {
3337
major: Number(semver.major(version)),
3438
minor: Number(semver.minor(version)),
3539
patch: Number(semver.patch(version)),
40+
concatenatedVersion: `${semver.major(version)}${semver.minor(version)}${semver.patch(version)}`,
3641
};
3742
return versions;
3843
};

0 commit comments

Comments
 (0)