Created
January 5, 2023 00:05
-
-
Save wojtekmaj/97a4bab5ddeabc748947029480bfa2bd to your computer and use it in GitHub Desktop.
Update all your dependencies in /, /sample, /sample/*, /test directories
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 | |
# Define function | |
update_dependencies() { | |
rm -rf yarn.lock | |
touch yarn.lock | |
yarn | |
yarn dedupe | |
} | |
# Update dependencies in root directory | |
update_dependencies | |
# Update dependencies in /sample and /test directories | |
if [ -d "sample" ]; then | |
# Change directory to /sample | |
cd sample | |
# Check if there is a package.json in root directory | |
if [ -f "package.json" ]; then | |
# Update dependencies in /sample directory | |
update_dependencies | |
else | |
# Find all subdirectories in /sample | |
for dir in */; do | |
# Change directory to subdirectory | |
cd $dir | |
# Update dependencies in subdirectory | |
update_dependencies | |
# Return to root directory | |
cd .. | |
done | |
fi | |
# Return to root directory | |
cd .. | |
fi | |
if [ -d "test" ]; then | |
# Change directory to /test | |
cd test | |
# Update dependencies in /test directory | |
update_dependencies | |
# Return to root directory | |
cd .. | |
fi | |
# Commit all updates | |
git commit -am "Update dependencies" | |
# Push changes to remote | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment