Skip to content

Commit 9f63e81

Browse files
authored
entr.sh: Run hpack when important files change
* hooks.sh: Run hpack when important files change * README.md: Recommend hooks.sh * entr.sh: Call hooks.sh by default * update.yml: Use stylish-haskell -r * Remove obsolete scripts
1 parent d8510a0 commit 9f63e81

File tree

10 files changed

+34
-436
lines changed

10 files changed

+34
-436
lines changed

.github/workflows/update.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ jobs:
5454
submodules: recursive
5555

5656
- name: Format with stylish-haskell
57-
run: |
58-
find . -type f -name '*.hs*' '(' ! -path '*/.stack-work*' ')' '(' ! -path '*/dist*' ')' -print0 | xargs -0L1 stylish-haskell -i
57+
run: stylish-haskell -i -r kore
5958

6059
- name: Commit changes
6160
uses: stefanzweifel/[email protected]

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ For setting up a development environment, we recommend:
6464
compatible with most editors. See instructions
6565
[below](#running-a-language-server) to run a language server.
6666
- [hlint] and [stylish-haskell] for compliance with project guidelines.
67+
- [entr] and [fd] for running `./entr.sh` to keep important files up-to-date.
68+
69+
We recommend to keep `./entr.sh` running in the background
70+
to keep important files (such as package descriptions) up-to-date,
71+
especially if the developer is using Cabal.
6772

6873
### Running a language server
6974

@@ -117,3 +122,5 @@ This script is also run by an automatic workflow.
117122
[stylish-haskell]: https://github.com/jaspervdj/stylish-haskell
118123
[kore.cachix.org]: https://kore.cachix.org/
119124
[Nix]: https://nixos.org
125+
[entr]: https://github.com/eradman/entr
126+
[fd]: https://github.com/sharkdp/fd

entr.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
# entr.sh: Run a command when project files change.
4+
5+
# Dependencies:
6+
# entr: https://github.com/eradman/entr
7+
# fd: https://github.com/sharkdp/fd
8+
9+
last=2 # last exit code
10+
11+
# entr runs the specified command whenever the listed files change,
12+
# and exits with code 2 when a file is added to any watched directory.
13+
# The loop restarts entr as long as it exits because of a new file.
14+
# If entr exits for any other reason, the loop is terminated.
15+
# This way, the script exits if the user interrupts it (for example).
16+
while test "$last" -eq 2
17+
do
18+
fd '(package.yaml|.*.hs)' | entr -d -s "${@:-./hooks.sh}"
19+
last=$?
20+
done

hooks.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
# hooks: run these commands when project files change
4+
5+
hpack -f kore
6+
stylish-haskell -i -r kore

scripts/check.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ export PATH="$HOME/.local/bin${PATH:+:}$PATH"
66

77
export TOP=${TOP:-$(git rev-parse --show-toplevel)}
88

9-
source $TOP/scripts/run-on-haskell.include.sh
10-
119
if ! $TOP/scripts/git-assert-clean.sh
1210
then
1311
echo >&2 "Please commit your changes!"

scripts/ci.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

scripts/lint.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

scripts/run-on-haskell.include.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

scripts/stylish.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)