#!/usr/bin/env bash

echo $(pwd)
ROOT=$(pwd)

LINT_PATH=$1

cd $LINT_PATH

echo "💼 prepare for linting package"

flutter pub get

if [ "$?" != "0" ]; then
    echo >&2 "🚫 Error: Prepare for linting failed";
    exit 1
fi

echo "🔬 linting nut_player package"
flutter analyze

if [ "$?" != "0" ]; then
    echo >&2 "🚫 Error: Linting Player failed";
    exit 1
fi

cd example

echo "💼 prepare for linting example"

flutter pub get

if [ "$?" != "0" ]; then
    echo >&2 "🚫 Error: Prepare for linting failed";
    exit 1
fi

echo "🔬 linting example"
flutter analyze

if [ "$?" != "0" ]; then
    echo >&2 "🚫 Error: Linting example failed";
    exit 1
fi

cd $ROOT
