-
-
Save joshburgess/fc2c22efd7647968d6a7201e3d8c0652 to your computer and use it in GitHub Desktop.
Run ghcid in a monorepo via stack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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