Skip to content

Instantly share code, notes, and snippets.

@gogones
Forked from parties/renameReactJsToJsx.sh
Created September 4, 2023 04:31
Show Gist options
  • Save gogones/242100bc31e7511f3c691ef3cefbbf2e to your computer and use it in GitHub Desktop.
Save gogones/242100bc31e7511f3c691ef3cefbbf2e to your computer and use it in GitHub Desktop.
rename all *.js files containing React markup to *.jsx
# finds all *.js files that have either `</` or `/>` tags in them and renames them to *.jsx
find ./src -type f -name '*.js' -not -name '*.jsx' -not -name '*.ejs' -exec bash -c 'grep -l -E "</|/>" "$0"' {} \; -exec bash -c 'mv "$0" "${0%.js}.jsx"' {} \;
@gogones
Copy link
Author

gogones commented Sep 5, 2023

for detected as git rename
find ./src -type f -name '*.js' -not -name '*.jsx' -not -name '*.ejs' -exec bash -c 'grep -l -E "</|/>" "$0"' {} \; -exec bash -c 'git mv "$0" "${0%.js}.jsx"' {} \;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment