Skip to content

Commit

Permalink
Add --reverse option to replace-fork script (facebook#20249)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
acdlite authored and koto committed Jun 15, 2021
1 parent 31d2a08 commit a475752
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/merge-fork/replace-fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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();

0 comments on commit a475752

Please sign in to comment.