From 2b6985114f660f3d0ad4c3eb8efece2cbdb44eb8 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Tue, 19 Jan 2021 17:14:06 +0100 Subject: [PATCH] build-combined: Fix failures when renaming across devices (#20620) --- scripts/rollup/build-all-release-channels.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/rollup/build-all-release-channels.js b/scripts/rollup/build-all-release-channels.js index 0b74e4c42d8e9..badd6f7c9ff02 100644 --- a/scripts/rollup/build-all-release-channels.js +++ b/scripts/rollup/build-all-release-channels.js @@ -3,6 +3,7 @@ /* eslint-disable no-for-of-loops/no-for-of-loops */ const fs = require('fs'); +const fse = require('fs-extra'); const {spawnSync} = require('child_process'); const path = require('path'); const tmp = require('tmp'); @@ -50,13 +51,13 @@ if (process.env.CIRCLE_NODE_TOTAL) { const stableVersion = '0.0.0-' + sha; buildForChannel('stable', '', ''); const stableDir = tmp.dirSync().name; - fs.renameSync('./build', stableDir); + crossDeviceRenameSync('./build', stableDir); processStable(stableDir, stableVersion); const experimentalVersion = '0.0.0-experimental-' + sha; buildForChannel('experimental', '', ''); const experimentalDir = tmp.dirSync().name; - fs.renameSync('./build', experimentalDir); + crossDeviceRenameSync('./build', experimentalDir); processExperimental(experimentalDir, experimentalVersion); // Then merge the experimental folder into the stable one. processExperimental @@ -68,7 +69,7 @@ if (process.env.CIRCLE_NODE_TOTAL) { // Now restore the combined directory back to its original name // TODO: Currently storing artifacts as `./build2` so that it doesn't conflict // with old build job. Remove once we migrate rest of build/test pipeline. - fs.renameSync(stableDir, './build2'); + crossDeviceRenameSync(stableDir, './build2'); } function buildForChannel(channel, nodeTotal, nodeIndex) { @@ -139,6 +140,10 @@ function processExperimental(buildDir, version) { } } +function crossDeviceRenameSync(source, destination) { + return fse.moveSync(source, destination, {overwrite: true}); +} + function updatePackageVersions(modulesDir, version) { const allReactModuleNames = fs.readdirSync('packages'); for (const moduleName of fs.readdirSync(modulesDir)) {