#!/usr/bin/env bash

GRAMMARS_DIR=$(dirname $0)/../spec/fixtures

GRAMMARS=(
  javascript
  json
  c
  cpp
)

for grammar in ${GRAMMARS[@]}; do
  echo "Fetching ${grammar} grammar..."

  grammar_dir=${GRAMMARS_DIR}/${grammar}
  grammar_url=https://github.com/tree-sitter/tree-sitter-${grammar}

  if [ ! -d $grammar_dir ]; then
    git clone $grammar_url $grammar_dir
  fi

  (
    cd $grammar_dir;
    git reset --hard;
    git pull origin master;
  )
done
