Skip to content

Instantly share code, notes, and snippets.

@brock
Last active September 7, 2017 15:25
Show Gist options
  • Save brock/0419aa6bba45bffcdb4c to your computer and use it in GitHub Desktop.
Save brock/0419aa6bba45bffcdb4c 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