Last active
May 16, 2019 14:43
-
-
Save eborden/569fb5de4c2b3de741d7bb643fe7c2d9 to your computer and use it in GitHub Desktop.
Run ghcid in a monorepo via stack
This file contains 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 |
usage:
cd package-1
stack-ghcid
cd package-2
stack-ghcid Some.Module.PathSpec
Credit to @5outh for starting the ball rolling with basename
and $1.spec
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This expects a monorepo with a single package depth directory structure