0

I want to use shake for regression testing and I have to set up the test directory. I would like to copy a directory with fonts into the test directory and included a need on the target directory and then copy the files but my code gives the error:

Probably due to calling 'need' on a directory. Shake only permits 'need' on files.

I tried to get needs on the single files, but do not succeed. I have

        fontFiles1 <- getDirectoryFiles (templatesD</>"et-book" ) ["/**/*"]
        need $ map (\f -> staticD</>"et-book"</>f) fontFiles1 

and then :

  (staticD</>"et-book/**") %> \out ->
        copyFileChanged  (replaceDirectory out (templatesD</>"et-book")) out

but this does not include all the subdirectories under et-book.

What is the right way to do this? Should I just copy all directory content over (with e.g. System.Path from fsutils)?

user855443
  • 2,596
  • 3
  • 25
  • 37

1 Answers1

1

This answer is correct in spirit, so I suspect there are just a few details that are slightly wrong:

  • Does fontFiles1 contain the complete list of files? My guess is the pattern should be **, and that the leading / is confusing things. Either way, ** would be simpler and more future proof.
  • The replaceDirectory replaces all directory components, so if you have static/et-book/foo/bar.txt, then you are going to copy from templates/et-book/bar.txt. Assuming you know staticD is always exactly one directory component, then templatesD</>dropDirectory1 out would work as a source location.

The pattern of copying a directory is pretty common, so I probably will add a helper function to make it easier in a future version. A ticket and discussion about that is happening on the Shake bug tracker.

Neil Mitchell
  • 9,090
  • 1
  • 27
  • 85
  • Thank you, it is good to know that it is ok in principle and I have just to work out the details with more attention. Thanks for adding a function... (by the way, I looked at the discussion of the bug tracker and took some inspiration from there, but I could not understanding the approach on simple reading). – user855443 Feb 08 '19 at 23:50