Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The ** pattern doesn't match files starting with dot symbol #841

Closed
arrowd opened this issue Apr 1, 2021 · 9 comments
Closed

The ** pattern doesn't match files starting with dot symbol #841

arrowd opened this issue Apr 1, 2021 · 9 comments
Labels

Comments

@arrowd
Copy link

arrowd commented Apr 1, 2021

I have data/.foo file as well as data/.hg directory in my Hakyll project. The following rule

match "data/**" $ do
  route idRoute
  compile copyFileCompiler

correctly copies all files and directories recursively, except .foo and .hg.

@Minoru Minoru added the question label Apr 1, 2021
@Minoru
Copy link
Collaborator

Minoru commented Apr 1, 2021

I think that's the correct behaviour. Since the pattern is specified as a string literal, IsString instance applies and calls fromGlob. There is no indication in the docs, but I believe globs are a Unix concept, and those are documented to only match filenames that do not start with a dot.

In order to match both, I think you'll have to use something like "data/**" .||. "data/**/.*" (I didn't test this though).

@arrowd
Copy link
Author

arrowd commented Apr 1, 2021

Unfortunately, data/**/.* didn't work too.

@Minoru
Copy link
Collaborator

Minoru commented Apr 1, 2021

How about fromRegex? Something like match (fromRegex "^data/.*") should match everything under the "data" directory, I think.

@arrowd
Copy link
Author

arrowd commented Apr 1, 2021

Nope, the regex works the same as glob with two stars. I guess, the problem lies deeper, in the filesystem visiting code.

@Minoru
Copy link
Collaborator

Minoru commented Apr 1, 2021

That'd be Hakyll.Core.Provider. I don't see anything suspicious in the code: it uses System.Directory.getDirectoryContents which returns everything, and it filters out just . and ... I won't dig deeper right now, so if you take a look and discover something, please share!

@Minoru
Copy link
Collaborator

Minoru commented Apr 10, 2021

@arrowd Did you manage to figure out what's wrong with the Provider?

@arrowd
Copy link
Author

arrowd commented Apr 10, 2021

Not yet, but it is on my TODO.

@arrowd
Copy link
Author

arrowd commented Apr 24, 2021

The problem stems from the default Configuration, the ignoreFile field:

    ignoreFile' path
        | "."    `isPrefixOf` fileName = True
        | "#"    `isPrefixOf` fileName = True
        | "~"    `isSuffixOf` fileName = True
        | ".swp" `isSuffixOf` fileName = True
        | otherwise                    = False

Overriding it for my site fixes the problem. I don't think that default should be changed, as it might suddenly make VCS directories visible for users.

@arrowd arrowd closed this as completed Apr 24, 2021
@Minoru
Copy link
Collaborator

Minoru commented Apr 24, 2021

Oh! So simple… Thank you for writing back! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants