#!/usr/bin/env bash

out="$(mktemp)"

node_modules/.bin/eslint "test/fixtures/**/*" \
  --config test/eslintrc.js \
  --ext .ts,.tsx \
  | sed "s|$(pwd)/||g" \
  > "$out"

if [ ! -f test/snapshot.txt ]; then
  echo "Snapshot written"
  cp "$out" test/snapshot.txt
fi

if diff -q "$out" test/snapshot.txt; then
  rm "$out"
  echo "OK"
  exit 0
else
  printf "\n==> Expected:\n"
  cat test/snapshot.txt
  printf "\n==>> Received:\n"
  cat "$out"
  rm "$out"
  exit 1
fi
