#!/bin/bash # Define the path to the node_modules directory NODE_MODULES_DIR="node_modules" # Check if node_modules directory exists if [ ! -d "$NODE_MODULES_DIR" ]; then echo "node_modules directory does not exist." else # Get the last modified time of the most recently modified file in node_modules LAST_MODIFIED=$(find "$NODE_MODULES_DIR" -type f -exec stat -f %m {} + | sort -n | tail -1) # Get the current time CURRENT_TIME=$(date +%s) # Calculate the age of node_modules in days AGE_DAYS=$(( (CURRENT_TIME - LAST_MODIFIED) / 86400 )) # Define the threshold for "old enough" (e.g., 7 days) THRESHOLD_DAYS=7 if [ "$AGE_DAYS" -ge "$THRESHOLD_DAYS" ]; then echo "node_modules is $AGE_DAYS days old." else echo "node_modules is up to date." fi fi