tree-sitter/script/generate-fixtures
dundargoc 5d1db069f5 test: add quotes around bash variables
This allows the script to work on directory names with spaces in them.

Co-authored-by: buckynbrocko <77247638+buckynbrocko@users.noreply.github.com>
2024-02-15 14:33:34 +01:00

33 lines
739 B
Bash
Executable file

#!/usr/bin/env bash
set -e
root_dir=$PWD
if [ "$CI" == true ]; then
set -x
tree_sitter="$TREE_SITTER"
else
cargo build --release
tree_sitter=${root_dir}/target/release/tree-sitter
fi
filter_grammar_name=$1
grammars_dir=${root_dir}/test/fixtures/grammars
grammar_files=$(find "$grammars_dir" -name grammar.js | grep -v node_modules)
while read -r grammar_file; do
grammar_dir=$(dirname "$grammar_file")
grammar_name=$(basename "$grammar_dir")
if [[ -n $filter_grammar_name && "$filter_grammar_name" != "$grammar_name" ]]; then
continue
fi
echo "Regenerating ${grammar_name} parser"
(
cd "$grammar_dir"
"$tree_sitter" generate src/grammar.json --no-bindings --abi=latest
)
done <<< "$grammar_files"