Last active
October 5, 2020 18:23
-
-
Save mjmaix/4f37e38ce8846ea02b931c9f9103c5f7 to your computer and use it in GitHub Desktop.
React Native cleanup scripts
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
{ | |
"scripts": { | |
"cleanup:all": "npm run cleanup:android && npm run cleanup:react && npm run cleanup:metrobundler && npm run cleanup:hastecache && npm run cleanup:ios", | |
"cleanup:react": "./scripts/killpackager.sh && watchman watch-del-all && rm -rf node_modules/ && rm -rf $TMPDIR/react-* ~/.npm/ ~./rncache", | |
"postcleanup:react": "echo 'run `npm install` or `yarn install`'", | |
"cleanup:ios": "rm -rf ~/Library/Developer/Xcode/DerivedData/* ios/build ios/Pods", | |
"cleanup:android": "./scripts/cleanandroid.sh", | |
"cleanup:metrobundler": "rm -rf /tmp/metro-bundler-cache-*", | |
"cleanup:hastecache": "rm -rf /tmp/haste-map-react-native-packager-*", | |
"start": "node node_modules/react-native/local-cli/cli.js start -- --reset-cache", | |
"postinstall": "./scripts/post.sh && npm run ios:pod:install", | |
"ios:pod:install": "cd ios && pod install" | |
} | |
} |
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 | |
DIRECTORY="node_modules/react-native" | |
if [ -d "$DIRECTORY" ]; then | |
echo "Running gradle clean" | |
cd ./android/ | |
./gradlew clean | |
echo "Finished cleaning up android" | |
fi |
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 | |
echo "💣 Killing Packager on port 8081." | |
lsof -n -i4TCP:8081 | sed '1 d' | awk '{print $2}' | xargs kill -9 |
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
# chmod +x scripts/post.sh | |
#!/bin/bash | |
echo "Something to do here." |
- update to avoid gradlew error when
node_modules/react-native
is missing
-
New android cleanup script
-
npm start kills - existing packager or other tasks using port 8081
- add kill package before cleanup:react
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All of the commands here can be executed separately. Don't be afraid to clean up your React Native project every once in a while of or when something unexpected happens. Doing a good cleanup first often saves the trouble of filing an issue ticket and waiting for someone else to suggest that you reinstall the app.. etc.
How to use:
Don't forget to close all Metrobundler (or the like) instances first before running.cleanup:all
and take a break