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

Exclude folders from glob-all #36

Merged
merged 2 commits into from
Jul 30, 2018
Merged

Exclude folders from glob-all #36

merged 2 commits into from
Jul 30, 2018

Conversation

wiljanslofstra
Copy link
Contributor

This fixes an error that occurs when a folder ends in one of the configured extensions (more info: #18). In my case I had a folder named jump.js. When using/running laravel-mix-purgecss I received the following error:

/Users/wiljanslofstra/Sites/project_name/node_modules/purgecss/lib/purgecss.js:678
                        throw _iteratorError5;
                        ^

Error: EISDIR: illegal operation on a directory, read
    at Object.fs.readSync (fs.js:675:18)
    at tryReadSync (fs.js:540:20)
    at Object.fs.readFileSync (fs.js:583:19)
    at Purgecss.extractFileSelector (/Users/wiljanslofstra/Sites/project_name/node_modules/purgecss/lib/purgecss.js:649:46)
    at Purgecss.purge (/Users/wiljanslofstra/Sites/project_name/node_modules/purgecss/lib/purgecss.js:409:41)
    at /Users/wiljanslofstra/Sites/project_name/node_modules/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.js:205:97
    at Array.forEach (<anonymous>)
    at /Users/wiljanslofstra/Sites/project_name/node_modules/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.js:155:39
    at Array.forEach (<anonymous>)
...and more

To prevent glob-all from matching folders ending in one of the extensions, I've added the option mark: true that adds slashes to the end of the path if it's a folder. And a filter that removes all paths ending in slashes (folders). This solution is copied from the glob-all documentation: https://github.com/jpillora/node-glob-all

module.exports = options => {
const globs = glob
.sync(options.globs, { mark: true })
.filter(function(f) { return !/\/$/.test(f); });
Copy link
Member

Choose a reason for hiding this comment

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

Could you use an arrow function here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sebastiandedeyne Of course 👍 Changed it in the last commit

@sebastiandedeyne sebastiandedeyne merged commit 0e0d4a6 into spatie:master Jul 30, 2018
@sebastiandedeyne
Copy link
Member

Thanks!

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.

None yet

2 participants