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
Parse nested gitignores correctly #203
Conversation
marionebl
commented
Apr 2, 2017
- Depends on Recursive glob patterns #201
- Credits for original bugfix go to @schnittstabil
85b3298
to
d24a0cd
Compare
Looks good to me. @marionebl Can you rebase on master? @schnittstabil Looks good to you? |
backport from #200
d24a0cd
to
437f425
Compare
@@ -6,21 +6,26 @@ import execa from 'execa'; | |||
|
|||
process.chdir(__dirname); | |||
|
|||
const cli = (...args) => { | |||
const cliPath = path.join(__dirname, '../cli.js'); |
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.
very minor: this can be done outside of the cli function
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.
Nah. It's not used outside the function, so better to keep it in context and it's doesn't really affect performance to keep it there.
Sorry, I dunno why I've missed this PR. I'll try to review it at this weekend. |
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.
Mostly minor changes.
options-manager.js
Outdated
.sync('**/.gitignore', { | ||
ignore: ignores, | ||
cwd: cwd | ||
}) |
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.
Just a small suggestion:
const getGitIgnores = opts => {
- const ignores = opts.ignores || [];
+ const ignore = opts.ignores || [];
const cwd = opts.cwd || process.cwd();
return globby
- .sync('**/.gitignore', {
- ignore: ignores,
- cwd: cwd
- })
+ .sync('**/.gitignore', {ignore, cwd})
.map(filename => {
const fullFilename = path.join(cwd, filename);
const patterns = parseGitignore(fullFilename);
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.
done
test/options-manager.js
Outdated
|
||
t.deepEqual(result, expected); | ||
process.chdir(previous); | ||
}); |
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.
Because of the test description, I believe the following makes more sense:
test('patterns should be translated according to process.cwd()', t => {
const previous = process.cwd();
- const cwd = path.join(__dirname, 'fixtures/gitignore/test');
+ const cwd = path.join(__dirname, 'fixtures/gitignore');
process.chdir(cwd);
const result = manager.getGitIgnores({});
- const expected = ['!foo.js', '!foo.js/**'];
+ const expected = ['!test/foo.js', '!test/foo.js/**'];
t.deepEqual(result, expected);
process.chdir(previous);
});
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.
Done!
f166b0f
to
30d4524
Compare
👍 LGTM |