Skip to content

Don't pass options.ignore to isGitIgnored#223

Merged
sindresorhus merged 1 commit intosindresorhus:mainfrom
fisker:git-ignore-ignore
Jan 20, 2022
Merged

Don't pass options.ignore to isGitIgnored#223
sindresorhus merged 1 commit intosindresorhus:mainfrom
fisker:git-ignore-ignore

Conversation

@fisker
Copy link
Copy Markdown
Collaborator

@fisker fisker commented Jan 20, 2022

ignore option in isGitIgnored() mean to ignore .gitignore files, but when running globby(), ignore mean to ignore matched files.

For example:

globbySync('**/*', {gitignore: true, ignore: ['.gitignore']})

This mean to glob all files that's not gitignored, but except .gitignore file, not mean don't read the .gitignore file.

Before:

> globbySync('**/*', {gitignore: true, ignore: ['.gitignore']}).filter(file => file.startsWith('node_modules')).length
11662

After:

> globbySync('**/*', {gitignore: true, ignore: ['.gitignore']}).filter(file => file.startsWith('node_modules')).length
0

This is a little hard to test, I didn't add.

@sindresorhus sindresorhus merged commit f816156 into sindresorhus:main Jan 20, 2022
@fisker fisker deleted the git-ignore-ignore branch January 20, 2022 08:56
@fisker
Copy link
Copy Markdown
Collaborator Author

fisker commented Jan 20, 2022

@sindresorhus After second thought, this ignore option for isGitIgnored doesn't make sense to me either, why someone want to skip reading a specific .gitignore file and let the result be true?

Do you think we should remove it?

@sindresorhus
Copy link
Copy Markdown
Owner

No idea. It was added a long time ago. I do agree with your reasoning though.

@fisker
Copy link
Copy Markdown
Collaborator Author

fisker commented Jan 20, 2022

It was added in #48, I think it's added for xo, maybe mean to check file is ignored by ignore option, but it never works that way.

@sindresorhus
Copy link
Copy Markdown
Owner

Yeah, let's remove it.

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.

2 participants