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

Should error if globbing inside with a path that is not a directory #235

Closed
willm opened this issue Nov 30, 2015 · 1 comment
Closed

Should error if globbing inside with a path that is not a directory #235

willm opened this issue Nov 30, 2015 · 1 comment

Comments

@willm
Copy link

willm commented Nov 30, 2015

I'm raising this because it's been the result of a 2 day bug hunt found through many libraries with a very vague error at the end which could have been avoided

assuming you have a directory /testDir containing file.txt. If you run:

glob('**/*.txt', { cwd: '/testDir/file.txt'}, function (err, dir) {
  console.log(err, dir);
});

you get: null, []

Should err not be something like new Error('Type error, cwd must be a directory') So that you know that it's a programmer error? I'm happy to make a pull request for this if you are happy with this suggestion.

@isaacs isaacs closed this as completed in 0ffab1f Feb 10, 2016
@isaacs
Copy link
Owner

isaacs commented Feb 10, 2016

Fixed on master. Had to bump the major, since this is raising a new error, and so it might cause a currently-working program to break.

Tough call, since it feels like a "bugfix" rather than a breaking change, but I've learned to err on the side of being overly cautious when it comes to raising errors for things that were previously allowed, even if they were incorrectly allowed.

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

No branches or pull requests

2 participants