cwd=$(pwd) for path in *; do if [ -d "$path" ]; then echo "rollup $path..." cd $path rollup index.js -o cjs/index.js -f cjs cd "$cwd" fi done