Skip to content

Instantly share code, notes, and snippets.

@joshburgess
Forked from eborden/stack-ghcid.sh
Created May 16, 2019 14:43
Show Gist options
  • Save joshburgess/fc2c22efd7647968d6a7201e3d8c0652 to your computer and use it in GitHub Desktop.
Save joshburgess/fc2c22efd7647968d6a7201e3d8c0652 to your computer and use it in GitHub Desktop.
Run ghcid in a monorepo via stack
project=$(basename "$(pwd)")
# build dependencies
build_deps="stack build $project --fast --pedantic --dependencies-only --interleaved-output"
# restart on changes in other packages
restarts=$(find ../. -maxdepth 1 -type d \
-not -name "$project" \
-not -name .stack-work \
-not -name . \
-printf '--restart %s ')
# define expression for testing
if [ -z "$1" ]; then
test_expression="main"
else
test_expression="Test.Hspec.hspec $1.spec"
fi
# define ghci execution command
execute_options="--interleaved-output --ghci-options '-fobject-code +RTS -N'"
execute="stack ghci $project\:lib $project\:spec $execute_options"
stack exec -- ghcid \
--command "$build_deps;$execute" \
--test "$test_expression" \
--restart package.yaml \
$restarts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment