Skip to content

Commit

Permalink
scripts/gen-hie.sh: Auto-symlink when safe to do so
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Jul 20, 2021
1 parent bf4d62e commit 038f712
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions scripts/gen-hie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,29 @@ echo "Generating $out. Some cabal builds may be necessary."

setup_cabal_plan

make_hie > $out
tmp=$(mktemp -d)
cleanup() { rm -rf "$tmp"; }
trap cleanup EXIT

make_hie > "$tmp/hie.yaml"
mv "$tmp/hie.yaml" $out

make_ghci > "$tmp/.ghci"
mv "$tmp/.ghci" $ghci

symlink() {
src="$1"
target="$2"

if [ ! -e "$target" ] || [ -L "$target" ]; then
ln -vsf "$src" "$target"
else
echo "Refusing to overwrite $target - check the file then run:"
echo " ln -sf $src $target"
fi
}

make_ghci > $ghci
symlink "$ghci" .ghci
symlink "$out" hie.yaml

echo "Finished. Type the following to enable your config:"
echo " ln -sf $out hie.yaml"
echo " ln -sf $ghci .ghci"
echo "Finished."

0 comments on commit 038f712

Please sign in to comment.