-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Drop support for checking object with path
property in function returns by isGitIgnored
#208
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,9 +34,9 @@ const checkCwdOption = options => { | |
} | ||
}; | ||
|
||
const getPathString = p => p.stats instanceof fs.Stats ? p.path : p; | ||
const getPathString = fastGlobResult => fastGlobResult.path || fastGlobResult; | ||
|
||
export const generateGlobTasks = (patterns, taskOptions = {}) => { | ||
export const generateGlobTasks = (patterns, taskOptions) => { | ||
patterns = arrayUnion([patterns].flat()); | ||
assertPatternsInput(patterns); | ||
|
||
|
@@ -95,9 +95,23 @@ const globDirectories = (task, fn) => { | |
|
||
const getPattern = (task, fn) => task.options.expandDirectories ? globDirectories(task, fn) : [task.pattern]; | ||
|
||
const getFilterSync = options => options && options.gitignore | ||
? isGitIgnoredSync({cwd: options.cwd, ignore: options.ignore}) | ||
: DEFAULT_FILTER; | ||
const getFilter = async options => { | ||
if (!options.gitignore) { | ||
return DEFAULT_FILTER; | ||
} | ||
|
||
const filter = await isGitIgnored({cwd: options.cwd, ignore: options.ignore}); | ||
return fastGlobResult => filter(getPathString(fastGlobResult)); | ||
}; | ||
|
||
const getFilterSync = options => { | ||
if (!options.gitignore) { | ||
return DEFAULT_FILTER; | ||
} | ||
|
||
const filter = isGitIgnoredSync({cwd: options.cwd, ignore: options.ignore}); | ||
return fastGlobResult => filter(getPathString(fastGlobResult)); | ||
}; | ||
|
||
const globToTask = task => async glob => { | ||
const {options} = task; | ||
|
@@ -123,13 +137,9 @@ const globToTaskSync = task => glob => { | |
}; | ||
}; | ||
|
||
export const globby = async (patterns, options) => { | ||
export const globby = async (patterns, options = {}) => { | ||
const globTasks = generateGlobTasks(patterns, options); | ||
|
||
const getFilter = async () => options && options.gitignore | ||
? isGitIgnored({cwd: options.cwd, ignore: options.ignore}) | ||
: DEFAULT_FILTER; | ||
|
||
const getTasks = async () => { | ||
const tasks = await Promise.all(globTasks.map(async task => { | ||
const globs = await getPattern(task, dirGlob); | ||
|
@@ -139,13 +149,13 @@ export const globby = async (patterns, options) => { | |
return arrayUnion(...tasks); | ||
}; | ||
|
||
const [filter, tasks] = await Promise.all([getFilter(), getTasks()]); | ||
const [filter, tasks] = await Promise.all([getFilter(options), getTasks()]); | ||
const paths = await Promise.all(tasks.map(task => fastGlob(task.pattern, task.options))); | ||
|
||
return arrayUnion(...paths).filter(path_ => !filter(getPathString(path_))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return arrayUnion(...paths).filter(path_ => !filter(path_)); | ||
}; | ||
|
||
export const globbySync = (patterns, options) => { | ||
export const globbySync = (patterns, options = {}) => { | ||
const globTasks = generateGlobTasks(patterns, options); | ||
|
||
const tasks = []; | ||
|
@@ -164,7 +174,7 @@ export const globbySync = (patterns, options) => { | |
return matches.filter(path_ => !filter(path_)); | ||
}; | ||
|
||
export const globbyStream = (patterns, options) => { | ||
export const globbyStream = (patterns, options = {}) => { | ||
const globTasks = generateGlobTasks(patterns, options); | ||
|
||
const tasks = []; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function mean to handle fastGlobResult, but
p.stats
is not always true, seeobjectMode
option infast-glob