Skip to content

Instantly share code, notes, and snippets.

@wojtekmaj
Created January 5, 2023 00:05
Show Gist options
  • Save wojtekmaj/97a4bab5ddeabc748947029480bfa2bd to your computer and use it in GitHub Desktop.
Save wojtekmaj/97a4bab5ddeabc748947029480bfa2bd to your computer and use it in GitHub Desktop.
Update all your dependencies in /, /sample, /sample/*, /test directories
#!/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