3
3
/* eslint-disable no-for-of-loops/no-for-of-loops */
4
4
5
5
const fs = require ( 'fs' ) ;
6
+ const fse = require ( 'fs-extra' ) ;
6
7
const { spawnSync} = require ( 'child_process' ) ;
7
8
const path = require ( 'path' ) ;
8
9
const tmp = require ( 'tmp' ) ;
@@ -50,13 +51,13 @@ if (process.env.CIRCLE_NODE_TOTAL) {
50
51
const stableVersion = '0.0.0-' + sha ;
51
52
buildForChannel ( 'stable' , '' , '' ) ;
52
53
const stableDir = tmp . dirSync ( ) . name ;
53
- fs . renameSync ( './build' , stableDir ) ;
54
+ crossDeviceRenameSync ( './build' , stableDir ) ;
54
55
processStable ( stableDir , stableVersion ) ;
55
56
56
57
const experimentalVersion = '0.0.0-experimental-' + sha ;
57
58
buildForChannel ( 'experimental' , '' , '' ) ;
58
59
const experimentalDir = tmp . dirSync ( ) . name ;
59
- fs . renameSync ( './build' , experimentalDir ) ;
60
+ crossDeviceRenameSync ( './build' , experimentalDir ) ;
60
61
processExperimental ( experimentalDir , experimentalVersion ) ;
61
62
62
63
// Then merge the experimental folder into the stable one. processExperimental
@@ -68,7 +69,7 @@ if (process.env.CIRCLE_NODE_TOTAL) {
68
69
// Now restore the combined directory back to its original name
69
70
// TODO: Currently storing artifacts as `./build2` so that it doesn't conflict
70
71
// with old build job. Remove once we migrate rest of build/test pipeline.
71
- fs . renameSync ( stableDir , './build2' ) ;
72
+ crossDeviceRenameSync ( stableDir , './build2' ) ;
72
73
}
73
74
74
75
function buildForChannel ( channel , nodeTotal , nodeIndex ) {
@@ -139,6 +140,10 @@ function processExperimental(buildDir, version) {
139
140
}
140
141
}
141
142
143
+ function crossDeviceRenameSync ( source , destination ) {
144
+ return fse . moveSync ( source , destination , { overwrite : true } ) ;
145
+ }
146
+
142
147
function updatePackageVersions ( modulesDir , version ) {
143
148
const allReactModuleNames = fs . readdirSync ( 'packages' ) ;
144
149
for ( const moduleName of fs . readdirSync ( modulesDir ) ) {
0 commit comments