Search code examples
continuous-integrationcicd

How to make CI/CD fail when the folder size is too large


We must prevent the uncontrolled growth of a dependency folder via developers.

./check_size.sh --limit 3GB ./node_modules ./packages/*/node_modules
# ^ fail if limit was overtaken 

Solution

  • I'm guessing bash is okay. Something like this?

    SIZE=`du -cs ./node_modules ./packagese/*/node_modules | cut -f 1 | tail -1`
    if [ $SIZE -gt 3145728 ]; then
       echo 'Too big'
       exit 1
    fi