Skip to content

Commit bd8bc5a

Browse files
authored
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.
1 parent 453df3f commit bd8bc5a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

scripts/merge-fork/replace-fork.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ const {promisify} = require('util');
88
const glob = promisify(require('glob'));
99
const {spawnSync} = require('child_process');
1010
const fs = require('fs');
11+
const minimist = require('minimist');
1112

1213
const stat = promisify(fs.stat);
1314
const copyFile = promisify(fs.copyFile);
1415

16+
const argv = minimist(process.argv.slice(2), {
17+
boolean: ['reverse'],
18+
});
19+
1520
async function main() {
1621
const oldFilenames = await glob('packages/react-reconciler/**/*.old.js');
1722
await Promise.all(oldFilenames.map(unforkFile));
@@ -42,7 +47,11 @@ async function unforkFile(oldFilename) {
4247
return;
4348
}
4449

45-
await copyFile(newFilename, oldFilename);
50+
if (argv.reverse) {
51+
await copyFile(oldFilename, newFilename);
52+
} else {
53+
await copyFile(newFilename, oldFilename);
54+
}
4655
}
4756

4857
main();

0 commit comments

Comments
 (0)