-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.sh
executable file
·44 lines (36 loc) · 1.14 KB
/
reset.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Description: Cleans up node_modules, dist, and coverage directories, then reinstalls dependencies.
# Usage: ./setup.sh
set -euo pipefail
# Function to check if required commands are available
function check_dependencies() {
local dependencies=("yarn" "rm")
for cmd in "${dependencies[@]}"; do
if ! command -v "$cmd" &> /dev/null; then
echo "Error: $cmd is not installed." >&2
exit 1
fi
done
}
# Function to determine the script directory
function get_script_dir() {
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd
}
# Function to clean directories
function cleanup_directories() {
echo "Removing node_modules, dist, and coverage directories..."
rm -rf "${SCRIPT_DIR}/node_modules" "${SCRIPT_DIR}/dist" "${SCRIPT_DIR}/coverage"
}
# Function to install dependencies
function install_dependencies() {
echo "Installing dependencies with yarn..."
cd "${SCRIPT_DIR}" && yarn install
}
# Main script execution
check_dependencies
SCRIPT_DIR=$(get_script_dir)
cleanup_directories
install_dependencies
echo "Running npx nx reset..."
npx nx reset
echo "Setup complete."