mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user