Skip to content

Instantly share code, notes, and snippets.

@whjvenyl
Forked from brock/modulesize.sh
Created September 7, 2017 15:25
Show Gist options
  • Save whjvenyl/86d225492d22b1ac38cc1c94133018ea to your computer and use it in GitHub Desktop.
Save whjvenyl/86d225492d22b1ac38cc1c94133018ea to your computer and use it in GitHub Desktop.
ModuleSize - shows the percentage of storage your node_modules are taking up
#!/bin/bash
ALL=$(du -s | awk '{print $1}');
NODEMODULES=$(find . -type d -depth 1 -name node_modules | xargs du -s | awk '{print $1}' | awk '{sum+=$1} END {print sum}');
DECIMAL=$(awk "BEGIN {printf \"%.2f\", $NODEMODULES/$ALL}")
PERCENT=$(echo "$DECIMAL*100" | bc)
echo "node_modules are using $PERCENT% of space in the current directory."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment