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

Added option to disable path check on parse #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const parse = (input, options = {}) => {
let filepath = options.path;

if (isParsed(input)) return input;
if (isValidPath(input) && fs.existsSync(input)) {
if (!(options.disablePathCheck || false) && isValidPath(input) && fs.existsSync(input)) {
filepath = input;
input = fs.readFileSync(input);
}
Expand Down
8 changes: 8 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ describe('gitignore', () => {
const name = '_gitignore_multiline_comments';
assert.equal(parse.format(fixture(name)), fixture(name));
});

it('should not try to load ignored files as an ignorefile', () => {
// if our ignore only includes a relative file that happens to be valid (e.g. package.json)
const content = 'package.json';
// it should not path check (otherwise would fail)
const parsed = parse(content, { disablePathCheck: true });
assert.equal(parsed.patterns, content);
});
});