#!/bin/bash
## Removes the composer installed version of the itinerator plugin and symlinks the local dev version instead.
## Run from the wordpress site root directory.
## itinerator-wp-plugin needs to be in the same parent folder as the wordpress site project.
root="$(dirname $PWD)"
cd 'web/app/plugins'
if [[ -L "itinerator" ]]; then
  echo "Already Linked!"
elif [[ -d "$root/itinerator-wp-plugin" ]]; then
  if  [[ -d "itinerator" ]]; then
    echo "Removing installed version of Itinerator from $PWD"
    rm -rf itinerator
  fi
  echo "Creating symlink to in $PWD to $root/itinerator-wp-plugin"
  ln -s $root/itinerator-wp-plugin itinerator
else
  echo "itinerator-wp-plugin not found in $root"
  echo "Using composer installed version instead."
fi
