#!/usr/bin/env bash

set -eo pipefail

script_dir="$(dirname "$0")"

args=()

# If the command is used like `yarn lint plugin` then set the target to `plugin/src`
if [ "$1" == "plugin" ]; then
  # Push the rest of the arguments minus the `plugin` arg
  args+=("${@:2}")
  args+=("plugin/src")
  if ! [[ -d plugin ]]; then
    # Good DX cuz Expo
    printf "\n\033[1;33mThe \`plugin/src\` folder does not exist in this project; please create it and try again.\033[0m\n\n"
    exit 0
  fi
else
  args+=("$@") 
  args+=("src") 
fi

"$script_dir/expo-module-eslint" "${args[@]}" 
