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

Upgrade fast-glob package to v3 #126

Merged
merged 7 commits into from
Jun 29, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Normalize glob pattern
fast-glob v3 does no longer convert slashes in glob pattern.
  • Loading branch information
yhatt committed Jun 25, 2019
commit f7f45abafcf542e3cccac45241fc0a4c8130a3b3
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
const fs = require('fs');
const path = require('path');
const arrayUnion = require('array-union');
const merge2 = require('merge2');
const glob = require('glob');
Expand Down Expand Up @@ -89,14 +90,16 @@ const getFilterSync = options => {
DEFAULT_FILTER;
};

const normalizeGlob = glob => glob.split(path.sep).join(path.posix.sep);
Copy link
Owner

Choose a reason for hiding this comment

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

Note:

Only forward-slashes in glob expression. Previously, we convert all slashes to the forward-slashes, which did not allow the use of escaping. See pattern syntax section in the README.md file. - https://github.com/mrmlnc/fast-glob/releases/tag/3.0.0

I don't think we should override that as the change was done for a good reason. Instead, we should update the tests and docs.

Copy link
Contributor Author

@yhatt yhatt Jun 26, 2019

Choose a reason for hiding this comment

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

I agree. An only concern at here is the glob pattern generated by dir-glob. It includes unexpected backslashes because of using path.join in Windows. (kevva/dir-glob#17)


const globToTask = task => glob => {
const {options} = task;
if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) {
options.ignore = dirGlob.sync(options.ignore);
options.ignore = dirGlob.sync(options.ignore).map(normalizeGlob);
}

return {
pattern: glob,
pattern: normalizeGlob(glob),
options
};
};
Expand Down