#!/usr/bin/env bash
set -e
DIR=`pwd`
if [ ! -e ".git/hooks/pre-commit" ]; then
rm -rf .git/hooks/pre-commit
mkdir -p .git/hooks
ln -s ../../.direnv/git/hooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
fi
init() {
if [ ! -d $DIR/$1/node_modules ] ; then
if ! [ -x "$(command -v pnpm)" ]; then
npm install -g pnpm
fi
cd $DIR/$1
pnpm i
cd $DIR
fi
}
init .
PATH_add $DIR/.direnv/bin