Skip to content

Instantly share code, notes, and snippets.

@yashsway
Created April 1, 2023 12:42
Show Gist options
  • Save yashsway/a6b0f7727be93c167eaeef517df68372 to your computer and use it in GitHub Desktop.
Save yashsway/a6b0f7727be93c167eaeef517df68372 to your computer and use it in GitHub Desktop.
Rename JS and JSX files to TSX (as part of a Typescript migration)
# rename all js to tsx
find . -type f \( -iname '*.js' -or -iname '*.jsx' \) -not -wholename '*node_modules*' -exec sh -c 'mv "$1" "${1%.js*}.tsx"' _ {} \;
# keep js files as ts
find . -type f \( -iname '*.js' -or -iname '*.jsx' \) -not -wholename '*node_modules*' -exec sh -c 'mv "$1" `sed -Ee "s/\.js(x)?$/\.ts\1/g" <<< "$1"`' _ {} \;
# credits to https://github.com/markogresak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment