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

Commit

Permalink
Merge pull request #31 from alexomanie/fix-version-comparison
Browse files Browse the repository at this point in the history
fix version comparison to make script work with react-script version 3.0.0
  • Loading branch information
Nargonath authored May 4, 2019
2 parents 25c413f + 29fb12a commit d348387
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 5 additions & 6 deletions scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ const {
} = require('../utils/cliHandler');
const { getReactScriptsVersion, isEjected } = require('../utils');

const { major, minor, patch } = getReactScriptsVersion(reactScriptsVersion);
const { major, minor, patch, concatenatedVersion } = getReactScriptsVersion(reactScriptsVersion);

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

const config =
major >= 2 && minor >= 1 && patch >= 2
Number(concatenatedVersion) >= 212
? (isEjected
? importCwd('./config/webpack.config')
: importCwd('react-scripts/config/webpack.config'))('development')
: isEjected
? importCwd('./config/webpack.config.dev')
: importCwd('react-scripts/config/webpack.config.dev');
? importCwd('./config/webpack.config.dev')
: importCwd('react-scripts/config/webpack.config.dev');

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

let inProgress = false;

fs
.emptyDir(paths.appBuild)
fs.emptyDir(paths.appBuild)
.then(() => {
spinner.succeed();

Expand Down
5 changes: 5 additions & 0 deletions utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const DEFAULT_VERSION = {
major: 2,
minor: 1,
patch: 2,
concatenatedVersion: '212',
};

exports.isEjected = fs.pathExistsSync(path.join(process.cwd(), 'config/paths.js'));
Expand All @@ -19,6 +20,9 @@ exports.getReactScriptsVersion = function getReactScriptsVersion(cliVersion) {
major: Number(semver.major(cliVersion)),
minor: Number(semver.minor(cliVersion)),
patch: Number(semver.patch(cliVersion)),
concatenatedVersion: `${semver.major(cliVersion)}${semver.minor(cliVersion)}${semver.patch(
cliVersion
)}`,
};
return versions;
}
Expand All @@ -33,6 +37,7 @@ exports.getReactScriptsVersion = function getReactScriptsVersion(cliVersion) {
major: Number(semver.major(version)),
minor: Number(semver.minor(version)),
patch: Number(semver.patch(version)),
concatenatedVersion: `${semver.major(version)}${semver.minor(version)}${semver.patch(version)}`,
};
return versions;
};

0 comments on commit d348387

Please sign in to comment.