brock
3/26/2015 - 10:06 PM

ModuleSize - shows the percentage of storage your node_modules are taking up

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."