Add --reverse option to replace-fork script (#20249)

When enabled, replaces new fork with old fork.

I've done this several times by manually editing the script file, so
seems useful enough to add an option.
This commit is contained in:
Andrew Clark
2020-11-13 11:09:02 -08:00
committed by GitHub
parent 453df3ff72
commit bd8bc5afce
+10 -1
View File
@@ -8,10 +8,15 @@ const {promisify} = require('util');
const glob = promisify(require('glob'));
const {spawnSync} = require('child_process');
const fs = require('fs');
const minimist = require('minimist');
const stat = promisify(fs.stat);
const copyFile = promisify(fs.copyFile);
const argv = minimist(process.argv.slice(2), {
boolean: ['reverse'],
});
async function main() {
const oldFilenames = await glob('packages/react-reconciler/**/*.old.js');
await Promise.all(oldFilenames.map(unforkFile));
@@ -42,7 +47,11 @@ async function unforkFile(oldFilename) {
return;
}
await copyFile(newFilename, oldFilename);
if (argv.reverse) {
await copyFile(oldFilename, newFilename);
} else {
await copyFile(newFilename, oldFilename);
}
}
main();