Skip to content

Commit 2b69851

Browse files
authored
build-combined: Fix failures when renaming across devices (#20620)
1 parent ba9582d commit 2b69851

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: scripts/rollup/build-all-release-channels.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/* eslint-disable no-for-of-loops/no-for-of-loops */
44

55
const fs = require('fs');
6+
const fse = require('fs-extra');
67
const {spawnSync} = require('child_process');
78
const path = require('path');
89
const tmp = require('tmp');
@@ -50,13 +51,13 @@ if (process.env.CIRCLE_NODE_TOTAL) {
5051
const stableVersion = '0.0.0-' + sha;
5152
buildForChannel('stable', '', '');
5253
const stableDir = tmp.dirSync().name;
53-
fs.renameSync('./build', stableDir);
54+
crossDeviceRenameSync('./build', stableDir);
5455
processStable(stableDir, stableVersion);
5556

5657
const experimentalVersion = '0.0.0-experimental-' + sha;
5758
buildForChannel('experimental', '', '');
5859
const experimentalDir = tmp.dirSync().name;
59-
fs.renameSync('./build', experimentalDir);
60+
crossDeviceRenameSync('./build', experimentalDir);
6061
processExperimental(experimentalDir, experimentalVersion);
6162

6263
// Then merge the experimental folder into the stable one. processExperimental
@@ -68,7 +69,7 @@ if (process.env.CIRCLE_NODE_TOTAL) {
6869
// Now restore the combined directory back to its original name
6970
// TODO: Currently storing artifacts as `./build2` so that it doesn't conflict
7071
// with old build job. Remove once we migrate rest of build/test pipeline.
71-
fs.renameSync(stableDir, './build2');
72+
crossDeviceRenameSync(stableDir, './build2');
7273
}
7374

7475
function buildForChannel(channel, nodeTotal, nodeIndex) {
@@ -139,6 +140,10 @@ function processExperimental(buildDir, version) {
139140
}
140141
}
141142

143+
function crossDeviceRenameSync(source, destination) {
144+
return fse.moveSync(source, destination, {overwrite: true});
145+
}
146+
142147
function updatePackageVersions(modulesDir, version) {
143148
const allReactModuleNames = fs.readdirSync('packages');
144149
for (const moduleName of fs.readdirSync(modulesDir)) {

0 commit comments

Comments
 (0)