We created a CLI tool that runs codemods with jscodeshift to batch refactor code. Usage:
yarn sg-codemod [...options]
where options
are:
--help
- display help--dry
- dry run (no changes are made to files)--glob
- use glob pattern to match files--jscodeshift
- pass options directly to jscodeshift
Use this flag to pass file path or directory through glob.
npx react-codemod --glob
You will be asked to type in path string in the next step. If you choose --glob
flag, that string (file path) will be interpreted with glob. Remember to include desired file extension(s) within the glob pattern, because all matching files will be passed to jscodeshift.
To pass more options directly to jscodeshift, use --jscodeshift="..."
. For example:
npx react-codemod --jscodeshift="--verbose=2"
See all available options here.
Replaces color
prop on a component to match new color tokens and/or refactored component API.