Last active
May 22, 2019 17:15
-
-
Save helielson/e501cdd1ebfaf18167c048bb0b5ed810 to your computer and use it in GitHub Desktop.
Rename javascript files to typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
echo "Rename files" | |
for file in $(find src/ -name "*.js" | grep -v __generated__ | grep -v __tests__); do | |
mv "$file" "${file%.js}.ts" | |
done | |
echo "Removing type import keyword..." | |
ag "import type" -l | grep -v __generated__ | xargs sed -i '' 's/import\ type/import/' | |
ag "import { type" -l | grep -v __generated__ | xargs sed -i '' 's/import\ {\ type/import\ {/' | |
ag ", { type" -l | grep -v __generated__ | xargs sed -i '' 's/,\ {\ type/,\ {/' | |
# this one below is dangerous... it can rename arguments too | |
# ag ", type" -l | grep -v __generated__ | xargs sed -i '' 's/, type/,/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment