-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
Ignore paths from .gitignore
#147
Merged
Merged
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
81cb471
Add --use-gitignore feature
juanj 4d703a5
Ignore the .gitignore files by default
juanj b9e5313
Inlcude description in readme
juanj c0eccb1
Order alphabetically.
juanj 4dfe33e
Move code to a new function
juanj 13d92cb
Add test
juanj 5703434
Change ignored directory to foo
juanj 012c30a
Requested changes.
juanj 57040c8
Remove trailing space
juanj 3566cf8
Add integration test
juanj 1009113
Use indexOf
juanj 2aa2776
Use map and reduce instead of forEach. Use path module.
juanj 9757062
Use path.join to generate the path to check.
juanj bf7d913
Ignore already ignored locations when searching for .gitignore
juanj 6e0e4af
Take in account XO cwd option
juanj 2f172b0
Change variable names
juanj ce27572
Resolve merge conflict
juanj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ const deepAssign = require('deep-assign'); | |
const multimatch = require('multimatch'); | ||
const resolveFrom = require('resolve-from'); | ||
const pathExists = require('path-exists'); | ||
const parseGitignore = require('parse-gitignore'); | ||
|
||
const DEFAULT_IGNORE = [ | ||
'**/node_modules/**', | ||
|
@@ -191,10 +192,20 @@ function groupConfigs(paths, baseOptions, overrides) { | |
return arr; | ||
} | ||
|
||
function getIgnores(opts) { | ||
const gitignore = parseGitignore('.gitignore'); | ||
|
||
opts.ignores = DEFAULT_IGNORE.concat(opts.ignores || []); | ||
opts.ignores = opts.ignores.concat(gitignore || []); | ||
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. No need for multiple concat statement. |
||
|
||
return opts; | ||
} | ||
|
||
function preprocess(opts) { | ||
opts = mergeWithPkgConf(opts); | ||
opts = normalizeOpts(opts); | ||
opts.ignores = DEFAULT_IGNORE.concat(opts.ignores || []); | ||
opts = getIgnores(opts); | ||
|
||
return opts; | ||
} | ||
|
||
|
@@ -208,3 +219,4 @@ exports.mergeApplicableOverrides = mergeApplicableOverrides; | |
exports.groupConfigs = groupConfigs; | ||
exports.preprocess = preprocess; | ||
exports.emptyOptions = emptyOptions; | ||
exports.getIgnores = getIgnores; |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This is a test .gitignore. | ||
foo/ |
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
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 needs to take into account the
cwd
option.