#!/usr/bin/env bash

STACK_WORK_SRC=.stack-work-${JOB}

#if [[ -e .stack-work.lock ]]; then
#  echo ".stack-work directory is locked (lock file exists); is another stack currently running?"
#  exit 1
#fi

touch .stack-work.lock
rm -rf .stack-work

if [[ ! -e "$STACK_WORK_SRC" ]]; then
  mkdir "$STACK_WORK_SRC"
  chmod 777 "$STACK_WORK_SRC"
fi

ln -s "$STACK_WORK_SRC" .stack-work