You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an unexpected issue. I did not realize you could pass a path to parse(input, options) and have it load.
I had a .gitignore with only a single line like this:
package-lock.json
And I was surprised to see the parse function returning the contents of my package-lock.json file. This can be inconvenient if not desired (I'd need to append either '#' or '\n' to what I read-in to disable).
I thought it might be nice to add an option to disable path checking. I created a PR that adds the option and a test for it.
// index.js line 32-36constparse=(input,options={})=>{letfilepath=options.path;if(isParsed(input))returninput;if(!(options.disablePathCheck||false)&&isValidPath(input)&&fs.existsSync(input)){// ....
// test.js +50-56it('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)constcontent='package.json';// it should not path check (otherwise would fail)constparsed=parse(content,{disablePathCheck: true});assert.equal(parsed.patterns,content);});
Thank you!
The text was updated successfully, but these errors were encountered:
kittems
changed the title
If a relative path is included in the .gitignore, it will be loaded as a gitignore
contribution: option to disable path check
Jul 9, 2023
Thank you so much for the library!
I ran into an unexpected issue. I did not realize you could pass a path to
parse(input, options)
and have it load.I had a .gitignore with only a single line like this:
And I was surprised to see the parse function returning the contents of my
package-lock.json
file. This can be inconvenient if not desired (I'd need to append either '#' or '\n' to what I read-in to disable).I thought it might be nice to add an option to disable path checking. I created a PR that adds the option and a test for it.
Thank you!
The text was updated successfully, but these errors were encountered: