@samitouri / QOS-React-2 / commits / ca15606d81

chore(build): Ensure experimental builds exists on windows (#20933)

* chore(build): Throw if `rsync` fails * did not get cwrsync to work

Sebastian Silbermann committed Mar 8, 2021 at 18:35 UTC ca15606d81374d85424e7dd4a48a8372d6c46701
1 file changed +21 -1
scripts/rollup/build-all-release-channels.js
+21 -1
@@ -64,7 +64,7 @@ if (process.env.CIRCLE_NODE_TOTAL) {
64 // will have already removed conflicting files.
65 //
66 // In CI, merging is handled automatically by CircleCI's workspace feature.
67 - spawnSync('rsync', ['-ar', experimentalDir + '/', stableDir + '/']);
67 + mergeDirsSync(experimentalDir + '/', stableDir + '/');
68
69 // Now restore the combined directory back to its original name
70 // TODO: Currently storing artifacts as `./build2` so that it doesn't conflict
@@ -186,3 +186,23 @@ function updateTheReactVersionThatDevToolsReads(version) {
186 `export default '${version}';\n`
187 );
188 }
189 +
190 +/**
191 + * cross-platform alternative to `rsync -ar`
192 + * @param {string} source
193 + * @param {string} destination
194 + */
195 +function mergeDirsSync(source, destination) {
196 + for (const sourceFileBaseName of fs.readdirSync(source)) {
197 + const sourceFileName = path.join(source, sourceFileBaseName);
198 + const targetFileName = path.join(destination, sourceFileBaseName);
199 +
200 + const sourceFile = fs.statSync(sourceFileName);
201 + if (sourceFile.isDirectory()) {
202 + fse.ensureDirSync(targetFileName);
203 + mergeDirsSync(sourceFileName, targetFileName);
204 + } else {
205 + fs.copyFileSync(sourceFileName, targetFileName);
206 + }
207 + }
208 +}