Skip to content

Instantly share code, notes, and snippets.

@isurfer21
Last active August 5, 2025 05:33
Show Gist options
  • Save isurfer21/3a8b51d2b00314ff1d409bd5bf3f3697 to your computer and use it in GitHub Desktop.
Save isurfer21/3a8b51d2b00314ff1d409bd5bf3f3697 to your computer and use it in GitHub Desktop.

Revisions

  1. isurfer21 revised this gist Aug 5, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions node_modules_age.sh
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,8 @@ NODE_MODULES_DIR="node_modules"
    if [ ! -d "$NODE_MODULES_DIR" ]; then
    echo "node_modules directory does not exist."
    else
    # Get the last modified time of node_modules
    LAST_MODIFIED=$(stat -f %m "$NODE_MODULES_DIR")
    # 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)
  2. isurfer21 created this gist Aug 5, 2025.
    27 changes: 27 additions & 0 deletions node_modules_age.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    #!/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 node_modules
    LAST_MODIFIED=$(stat -f %m "$NODE_MODULES_DIR")

    # 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