Skip to content

Commit

Permalink
[core] Allow dist tag as argv in use-react-dist-tag
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jul 16, 2020
1 parent 1f393d5 commit dcbf778
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/use-react-dist-tag.js
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
/**
* Given an environment variable called `REACT_DIST_TAG` fetch the corresponding
* Given the dist tag fetch the corresponding
* version and make sure this version is used throughout the repository.
*
* If you work on this file:
Expand All @@ -18,7 +18,8 @@ const exec = promisify(childProcess.exec);
// packages published from the react monorepo using the same version
const reactPackageNames = ['react', 'react-dom', 'react-is', 'react-test-renderer', 'scheduler'];

async function main(distTag) {
async function main(options) {
const { distTag } = options;
if (typeof distTag !== 'string') {
throw new TypeError(`expected distTag: string but got '${distTag}'`);
}
Expand Down Expand Up @@ -54,7 +55,8 @@ async function main(distTag) {
await exec(`git apply ${path.resolve(__dirname, `./react-${distTag}.diff`)}`);
}

main(process.env.REACT_DIST_TAG).catch((error) => {
const [distTag = process.env.REACT_DIST_TAG] = process.argv.slice(2);
main({ distTag }).catch((error) => {
console.error(error);
process.exit(1);
});

0 comments on commit dcbf778

Please sign in to comment.