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>
This commit is contained in:
dundargoc 2024-02-15 14:07:27 +01:00 committed by dundargoc
parent 665f5a0793
commit 5d1db069f5
2 changed files with 7 additions and 7 deletions

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash
GRAMMARS_DIR=$(dirname $0)/../test/fixtures/grammars
GRAMMARS_DIR=$(dirname "$0")/../test/fixtures/grammars
fetch_grammar() {
local grammar=$1
@ -10,13 +10,13 @@ fetch_grammar() {
echo "Updating ${grammar} grammar..."
if [ ! -d $grammar_dir ]; then
git clone $grammar_url $grammar_dir --depth=1
if [ ! -d "$grammar_dir" ]; then
git clone "$grammar_url" "$grammar_dir" --depth=1
fi
(
cd $grammar_dir
git fetch origin $ref --depth=1
cd "$grammar_dir" || exit
git fetch origin "$ref" --depth=1
git reset --hard FETCH_HEAD
)
}

View file

@ -15,7 +15,7 @@ fi
filter_grammar_name=$1
grammars_dir=${root_dir}/test/fixtures/grammars
grammar_files=$(find $grammars_dir -name grammar.js | grep -v node_modules)
grammar_files=$(find "$grammars_dir" -name grammar.js | grep -v node_modules)
while read -r grammar_file; do
grammar_dir=$(dirname "$grammar_file")
@ -27,7 +27,7 @@ while read -r grammar_file; do
echo "Regenerating ${grammar_name} parser"
(
cd $grammar_dir
cd "$grammar_dir"
"$tree_sitter" generate src/grammar.json --no-bindings --abi=latest
)
done <<< "$grammar_files"