Skip to content

Commit

Permalink
did not get cwrsync to work
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Mar 5, 2021
1 parent 660e415 commit b772bfe
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions scripts/rollup/build-all-release-channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,7 @@ if (process.env.CIRCLE_NODE_TOTAL) {
// will have already removed conflicting files.
//
// In CI, merging is handled automatically by CircleCI's workspace feature.
const {error} = spawnSync('rsync', [
'-ar',
experimentalDir + '/',
stableDir + '/',
]);
if (error !== undefined) {
if (error.code === 'ENOENT') {
throw new Error(
`${process.argv[1]} needs the \`rsync\` CLI installed to work.`
);
}
throw error;
}
mergeDirsSync(experimentalDir + '/', stableDir + '/');

// Now restore the combined directory back to its original name
// TODO: Currently storing artifacts as `./build2` so that it doesn't conflict
Expand Down Expand Up @@ -198,3 +186,23 @@ function updateTheReactVersionThatDevToolsReads(version) {
`export default '${version}';\n`
);
}

/**
* cross-platform alternative to `rsync -ar`
* @param {string} source
* @param {string} destination
*/
function mergeDirsSync(source, destination) {
for (const sourceFileBaseName of fs.readdirSync(source)) {
const sourceFileName = path.join(source, sourceFileBaseName);
const targetFileName = path.join(destination, sourceFileBaseName);

const sourceFile = fs.statSync(sourceFileName);
if (sourceFile.isDirectory()) {
fse.ensureDirSync(targetFileName);
mergeDirsSync(sourceFileName, targetFileName);
} else {
fs.copyFileSync(sourceFileName, targetFileName);
}
}
}

0 comments on commit b772bfe

Please sign in to comment.