added scripts

This commit is contained in:
Ronald A. Richardson
2023-12-07 11:17:52 +08:00
parent d60760104d
commit 0a3ad2f0a6
2 changed files with 47 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
#!/bin/bash
# Find the root directory of your repository
root_dir=$(git rev-parse --show-toplevel)
# Check if the packages directory exists
packages_dir="$root_dir/packages"
if [ ! -d "$packages_dir" ]; then
echo "Packages directory not found."
exit 1
fi
# Check for the command-line argument to remove pnpm-lock.yaml
remove_lock=false
if [ "$1" == "--remove-lock" ]; then
remove_lock=true
fi
# Navigate to the packages directory
cd "$packages_dir"
# Find all child directories and run pnpm install if package.json exists
for dir in */; do
if [[ -f "${dir}package.json" ]]; then
echo "Running pnpm install in $dir"
# Remove pnpm-lock.yaml if the option is set
if [ "$remove_lock" = true ] && [ -f "${dir}pnpm-lock.yaml" ]; then
echo "Removing pnpm-lock.yaml in $dir"
rm "${dir}pnpm-lock.yaml"
fi
cd "$dir"
pnpm install
cd "$packages_dir" # Go back to the packages directory
else
echo "No package.json found in $dir, skipping..."
fi
done