Skip to content

Commit

Permalink
build-combined: Fix failures when renaming across devices (facebook#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored and koto committed Jun 15, 2021
1 parent f60fa2c commit c203b86
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/rollup/build-all-release-channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit c203b86

Please sign in to comment.