Skip to content

Commit 47664de

Browse files
authored
Allow running download_devtools_regression_build.js on a clean repo (#34456)
1 parent 5502d85 commit 47664de

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

scripts/ci/download_devtools_regression_build.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const semver = require('semver');
99
const yargs = require('yargs');
1010
const fs = require('fs');
1111

12-
const INSTALL_PACKAGES = ['react-dom', 'react', 'react-test-renderer'];
1312
const REGRESSION_FOLDER = 'build-regression';
1413

1514
const ROOT_PATH = join(__dirname, '..', '..');
@@ -23,6 +22,12 @@ const version = process.argv[2];
2322
const shouldReplaceBuild = !!argv.replaceBuild;
2423

2524
async function downloadRegressionBuild() {
25+
const reactVersion = semver.coerce(version).version;
26+
const installPackages = ['react-dom', 'react', 'react-test-renderer'];
27+
if (semver.gte(reactVersion, '16.3.0')) {
28+
installPackages.push('react-is');
29+
}
30+
2631
console.log(chalk.bold.white(`Downloading React v${version}\n`));
2732

2833
// Make build directory for temporary modules we're going to download
@@ -35,7 +40,7 @@ async function downloadRegressionBuild() {
3540
await exec(`mkdir ${regressionBuildPath}`);
3641

3742
// Install all necessary React packages that have the same version
38-
const downloadPackagesStr = INSTALL_PACKAGES.reduce(
43+
const downloadPackagesStr = installPackages.reduce(
3944
(str, name) => `${str} ${name}@${version}`,
4045
''
4146
);
@@ -51,7 +56,7 @@ async function downloadRegressionBuild() {
5156

5257
// Remove all the packages that we downloaded in the original build folder
5358
// so we can move the modules from the regression build over
54-
const removePackagesStr = INSTALL_PACKAGES.reduce(
59+
const removePackagesStr = installPackages.reduce(
5560
(str, name) => `${str} ${join(buildPath, name)}`,
5661
''
5762
);
@@ -63,12 +68,12 @@ async function downloadRegressionBuild() {
6368
.join(' ')}\n`
6469
)
6570
);
66-
await exec(`rm -r ${removePackagesStr}`);
71+
await exec(`rm -rf ${removePackagesStr}`);
6772

6873
// Move all packages that we downloaded to the original build folder
6974
// We need to separately move the scheduler package because it might
7075
// be called schedule
71-
const movePackageString = INSTALL_PACKAGES.reduce(
76+
const movePackageString = installPackages.reduce(
7277
(str, name) => `${str} ${join(regressionBuildPath, 'node_modules', name)}`,
7378
''
7479
);
@@ -80,9 +85,9 @@ async function downloadRegressionBuild() {
8085
.join(' ')} to ${chalk.underline.blue(buildPath)}\n`
8186
)
8287
);
88+
fs.mkdirSync(buildPath, {recursive: true});
8389
await exec(`mv ${movePackageString} ${buildPath}`);
8490

85-
const reactVersion = semver.coerce(version).version;
8691
// For React versions earlier than 18.0.0, we explicitly scheduler v0.20.1, which
8792
// is the first version that has unstable_mock, which DevTools tests need, but also
8893
// has Scheduler.unstable_trace, which, although we don't use in DevTools tests
@@ -100,7 +105,7 @@ async function downloadRegressionBuild() {
100105
);
101106
} else {
102107
console.log(chalk.white(`Downloading scheduler\n`));
103-
await exec(`rm -r ${join(buildPath, 'scheduler')}`);
108+
await exec(`rm -rf ${join(buildPath, 'scheduler')}`);
104109
await exec(
105110
`mv ${join(
106111
regressionBuildPath,
@@ -134,8 +139,6 @@ async function main() {
134139
return;
135140
}
136141
await downloadRegressionBuild();
137-
} catch (e) {
138-
console.log(chalk.red(e));
139142
} finally {
140143
// We shouldn't remove the regression-build folder unless we're using
141144
// it to replace the build folder

0 commit comments

Comments
 (0)