#!/bin/bash
OUTFILE=$(npm pack | tail -n 1)
cd ../server || exit
echo "install in ../server"
echo "$OUTFILE created"
# Don't install if currently installed as a symlinked package
if [[ -L "./node_modules/@devctrl/data-model" ]]; then
  echo "skipping symlinked package server/node_modules/@devctrl/data-model"
else
  npm i ../data-model/"$OUTFILE"
fi
cd ../webapp || exit
echo "installing in ../webapp"
npm i ../data-model/"$OUTFILE"
cd ../fetchers || exit
echo "installing in ../fetchers"
if [[ -L "./node_modules/@devctrl/data-model" ]]; then
  echo "skipping symlinked package fetchers/node_modules/@devctrl/data-model"
else
  npm i ../data-model/"$OUTFILE"
fi
cd ../puters-model || exit
echo "installing in ../puters-model"
npm i ../data-model/"$OUTFILE"