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

Enable "exclude:" and "include:" options for files in asset folder (fix #3881) #3882

Conversation

seaoak
Copy link
Member

@seaoak seaoak commented Nov 22, 2019

What does it do?

Fix #3881

exlucde: option and include: option in _config.yml is no effect for files in Asset Folder.
These are only effect for files outside of source/_post/
(such as source/foo.jpg, source/foo/bar.jpg).

This behavior does not match its document.
https://hexo.io/docs/configuration#Include-Exclude-Files-or-Folders

This patch fixes this behavior.

How to test

git clone -b feature/enable-exclude-and-include-options-for-files-in-asset-folder https://github.com/seaoak/hexo.git
cd hexo
npm install
npm test

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 97.148% when pulling 4775a2c on seaoak:feature/enable-exclude-and-include-options-for-files-in-asset-folder into 2146a03 on hexojs:master.

@curbengh
Copy link
Contributor

To clarify, the issue is that currently exclude: and include: doesn't work on post asset folder?

For example:
source/_posts/a_post/index.md + source/_posts/a_post/foo.jpg

and exclude: **/*.jpg doesn't work, even though it should work in every folder/subfolder of source/. Is my understanding correct?

@curbengh curbengh added this to the v4.1.0 milestone Nov 23, 2019
@seaoak
Copy link
Member Author

seaoak commented Nov 24, 2019

@curbengh Yes.
This patch is only for asset files, not for post itself.
To exclude a post, skip_render: option should be used (as described in the sample code in the document).

@curbengh
Copy link
Contributor

_config.yml
post_asset_folder: true

Working:

File structure:
source/_posts/a-post.md
source/_posts/a-post/foo.txt
source/_posts/a-post/_bar.txt

Tested patterns:

  • include: '**.txt'
  • include: '*.txt'
  • include: '**/*.txt
  • exclude: '**.txt'
  • exclude: '*.txt'
  • exclude: '**/*.txt'
  • include: '_bar.txt' + exclude: 'foo.txt'

Not working

File structure:
source/_posts/a-post.md
source/_posts/a-post/img/foo.txt
source/_posts/a-post/img/_bar.txt

Tested patterns:

  • exclude: '**.txt'
  • exclude: '**/img/*.txt'

include: '**.txt' did work though.

@curbengh curbengh modified the milestone: v4.1.0 Nov 27, 2019
@curbengh
Copy link
Contributor

curbengh commented Nov 27, 2019

@seaoak

We are planning to release 4.1.0, do you think you can fix the exclude: '**/img/*.txt' in time?

I don't mind including this PR with that shortcoming in 4.1.0 (since this PR at current stage already sufficient for #3881), and then address it later in 4.1.1/4.2.0.

@seaoak
Copy link
Member Author

seaoak commented Nov 27, 2019

@curbengh I think this PR will target to 4.1.1/4.2.0.

I think that the fix is not easy because subdirectories of asset folders seem to be not considered right way.
I'll continue to investigate codes! 💪

Copy link
Contributor

@curbengh curbengh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current coverage is sufficient for the use case of #3881. Coverage can be improved in future.

@curbengh curbengh mentioned this pull request Dec 1, 2019
1 task
@curbengh curbengh merged commit e423773 into hexojs:master Dec 1, 2019
@seaoak
Copy link
Member Author

seaoak commented Dec 1, 2019

@curbengh Thank you your following.
I'll make a new PR for subdirectories in Assert Folder. 😄

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

Successfully merging this pull request may close these issues.

Config Exclude is not excluding file types
4 participants