<commit_before>#!/bin/bash

main() {
    local remove_only="$1"
    local cwd="$PWD";
    for name in $(yarn --silent lerna list --toposort); do
        local package="${name#\@terascope/}"
        if [ -z "$remove_only" ] || [ "$remove_only" == "dist" ]; then
            local dist_dir="$cwd/packages/$package/dist"
            if [ -d "$dist_dir" ]; then
                rm -rf "${dist_dir:?}"/*
            fi
        fi

        if [ -z "$remove_only" ] || [ "$remove_only" == "build" ]; then
            local build_dir="$cwd/packages/$package/build"
            if [ -d "$build_dir" ]; then
                rm -rf "$build_dir"
            fi
        fi
    done
}

main "$@"
<commit_msg>fix: build-cleanup script to avoid issues with reloading vscode<commit_after>#!/bin/bash

main() {
    local remove_only="$1"
    local cwd="$PWD";
    for name in $(yarn --silent lerna list --toposort); do
        local package="${name#\@terascope/}"
        if [ -z "$remove_only" ] || [ "$remove_only" == "dist" ]; then
            local dist_dir="$cwd/packages/$package/dist"
            if [ -d "$dist_dir" ]; then
                # delete all files except the dist/src/index
                # to avoid reloading vscode
                find "$dist_dir" \
                    -not -path '*src/index*' \
                    -and \
                    -not -name 'dist' \
                    -print0 | xargs rm -r --
            fi
        fi

        if [ -z "$remove_only" ] || [ "$remove_only" == "build" ]; then
            local build_dir="$cwd/packages/$package/build"
            if [ -d "$build_dir" ]; then
                rm -rf "$build_dir"
            fi
        fi
    done
}

main "$@"

{'fraction_non_alphanumeric': 0.15566037735849056, 'fraction_numerical': 0.001768867924528302, 'mean_word_length': 1.5103550295857988, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2453636', 'n_tokens_mistral': 541, 'n_tokens_neox': 519, 'n_words': 134}