BASH
Automate Project Dependency Installation
Streamline project setup by automatically detecting and installing Node.js, Python, or Ruby dependencies based on common lock files, saving development time.
#!/bin/bash
echo "Checking for project dependencies..."
if [ -f "package.json" ]; then
echo "Node.js project detected. Installing dependencies with npm..."
npm install
elif [ -f "requirements.txt" ]; then
echo "Python project detected. Installing dependencies with pip..."
pip install -r requirements.txt
elif [ -f "Gemfile" ]; then
echo "Ruby project detected. Installing dependencies with bundler..."
bundle install
else
echo "No common dependency files (package.json, requirements.txt, Gemfile) found."
echo "If this is a different type of project, please install dependencies manually."
fi
echo "Dependency check complete."
How it works: This script automates the installation of project dependencies by checking for common package manager configuration files. It first looks for `package.json` for Node.js projects and runs `npm install`. If not found, it checks for `requirements.txt` for Python projects and runs `pip install -r`. Finally, it checks for `Gemfile` for Ruby projects and executes `bundle install`. This simplifies the initial setup for new developers or CI/CD pipelines.