> Thanks, that worked! Would be great to add to the documentation:
>
> stack install shake
> stack exec -- shake --demo
Yep, now I know it works I'll add it - I've raised a ticket.
https://github.com/ndmitchell/shake/issues/435
> Unrelated (apologies for hijacking). I'm super new to shake and have been
> really enjoying working with it; one pattern I've been running into is a
> phonyish target that has a dependency on files but generates no output -
> it's transforming the files (e.g., lint, formatting, etc.). So I'm using a
> "dummy" file under the build directory to track whether the phony target
> needs to be run or not - it looks something like this:
So the formatting/lint seem to fall into two different models:
1) For things where it takes in a file and modifies it, you probably
want to have the input and output be different files, and then Shake
handles it nicely. If you don't have the input and output be different
files, you definitely need to record that it ran, and a fake file is
probably the easiest way to do that. One option would be to make the
rule produce a backup file of the original contents, just in case you
decide stylish or whatever went off the rails and broke your file.
Generating custom rules which don't produce the file is a bit complex
right now, but I'm working on making it easier, so I might have a
better answer shortly.
2) For things like linting which produce a report, I recommend putting
the report in a file, and treating the report as output. That way you
can go back and look at the lint output for the current state, which
is often quite useful.
> fake :: FilePath -> Action a -> Rules ()
> fake target act = do
> buildDir </> target %> \out ->
> act >> writeFile' out mempty
>
> phony target $
> need [ buildDir </> target ]
This looks quite a reasonable approach. Only downside is that you run
stylish on all files if any of them change, but to do better you'd
need a fake file per Haskell file, which might be less desirable, and
running styling on everything might not take that long anyway.
Thanks, Neil