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.
Andrew Clark committed
Nov 13, 2020 at 13:09 UTC
bd8bc5afce51a95b7223b5ae57960d2d001fbafa
1 file changed
+10
-1
scripts/merge-fork/replace-fork.js
+10
-1
@@ -8,10 +8,15 @@ const {promisify} = require('util');
8
const glob = promisify(require('glob'));
9
const {spawnSync} = require('child_process');
10
const fs = require('fs');
11
+const minimist = require('minimist');
12
13
const stat = promisify(fs.stat);
14
const copyFile = promisify(fs.copyFile);
15
16
+const argv = minimist(process.argv.slice(2), {
17
+ boolean: ['reverse'],
18
+});
19
+
20
async function main() {
21
const oldFilenames = await glob('packages/react-reconciler/**/*.old.js');
22
await Promise.all(oldFilenames.map(unforkFile));
@@ -42,7 +47,11 @@ async function unforkFile(oldFilename) {
47
return;
48
}
49
45
- await copyFile(newFilename, oldFilename);
50
+ if (argv.reverse) {
51
+ await copyFile(oldFilename, newFilename);
52
+ } else {
53
+ await copyFile(newFilename, oldFilename);
54
+ }
55
}
56
57
main();