33/* eslint-disable no-for-of-loops/no-for-of-loops */
44
55const fs = require ( 'fs' ) ;
6+ const fse = require ( 'fs-extra' ) ;
67const { spawnSync} = require ( 'child_process' ) ;
78const path = require ( 'path' ) ;
89const 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
7475function 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+
142147function updatePackageVersions ( modulesDir , version ) {
143148 const allReactModuleNames = fs . readdirSync ( 'packages' ) ;
144149 for ( const moduleName of fs . readdirSync ( modulesDir ) ) {
0 commit comments