on master help sign in
Make sure we always get both original and formatted files
78e8dd8mrkkrp
README.md+3−1
@@ -74,7 +74,9 @@ $ nix-build -A hackage.<package>
74```
74```
75
75
76Then inspect `result/log.txt` for possible problems. The derivation will
76Then inspect `result/log.txt` for possible problems. The derivation will
77−also contain formatted files for inspection.
77+also contain formatted `.hs` files for inspection and original inputs with
78+`.hs-original` extension (those are with CPP dropped, exactly what is fed
79+into Ormolu).
78
80
79## Contributing
81## Contributing
80
82
nix/ormolize/default.nix+1
@@ -13,6 +13,7 @@
13 '';
13 '';
14 installPhase = ''
14 installPhase = ''
15 mkdir "$out"
15 mkdir "$out"
16+ find . -name '*.hs-original' -exec cp --parents {} $out \;
16 find . -name '*.hs' -exec cp --parents {} $out \;
17 find . -name '*.hs' -exec cp --parents {} $out \;
17 cp log.txt $out/log.txt
18 cp log.txt $out/log.txt
18 '';
19 '';
nix/ormolize/ormolize.sh+4−1
@@ -14,5 +14,8 @@ cpphs "$1" --noline > "$1-nocpp" 2> /dev/null
14# annoyingly, cpphs cannot modify files in place
14# annoyingly, cpphs cannot modify files in place
15mv "$1-nocpp" "$1"
15mv "$1-nocpp" "$1"
16
16
17+# preserve the original
18+cp "$1" "$1-original"
19+
17# run ormolu
20# run ormolu
18−ormolu -m inplace "$1"
21+ormolu -m inplace "$1" || ormolu -u -m inplace "$1"