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
Emit error on file not found with singular globs #41
Conversation
should.fail(); | ||
}); | ||
|
||
// For some reason `end` isn't called unless `data` is first? |
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.
I don't know wtf is happening here, for some reason end
is never called unless I add a listener to data
(which is never called, too).
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.
@callumacrae yeah the stream has to be put into a flowing state, they are paused by default. adding a data handler or calling .resume will do it for you. you can also pipe it somewhere, but resume is probably easiest for this test
if (positives.length === 1) { | ||
return streamFromPositive(positives[0]); | ||
} else { | ||
opt.allowEmpty = true; |
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.
opt.allowEmpty should be true by default, probably best to use lodash.defaults
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.
It is true by default, this is just stopping errors from being thrown when there's multiple paths in the array (see the "should not emit error when multiple globs not found" test).
I guess this could be considered an abuse of configuration, but it's certainly the easiest way to do it.
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.
Uh, ignore what I just said. You said in the gulp issue that it should be false by default (so, it throws an error if an option isn't specified). Have you changed your mind?
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.
@callumacrae Sorry, late night when I said that. false by default.
I think this PR was based on the assumption that it should only fail if one direct path is passed in, but it should also fail for gulp.src(['a.js', 'b.js']) if either a or b are not found and also gulp.src(['a.js', 'b*.js']) if a.js is not found |
var stream = gs.create('notfound{a,b}'); | ||
should.exist(stream); | ||
stream.on('error', function() { | ||
should.fail(); |
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.
for these tests i would usually do done('Error was emitted')
that way if it does fail you have a more descriptive message
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.
I'm going with throw new Error('Error was emitted');
, because otherwise it just complains that done()
is being called twice. I figure I could also just use _.once(done)
, but I don't see any advantage over this.
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.
@callumacrae same effect, works for me
Would that behaviour be as intuitive? It's also waay trickier to implement. I can't figure out how I would do it, because the |
@callumacrae Any direct path should fail if it wasn't found, only doing so when one is specified seems like the unintuitive route |
Also you do have access to the glob in match events https://github.com/callumacrae/glob-stream/blob/empty-error/index.js#L39 ourGlob is within scope |
Done. Not sure if the weird error emitting stuff I'm doing is the best way, but I don't know any other. I got confused by the whole create / createStream thing, I thought it would be trickier. |
@@ -95,8 +103,13 @@ var gs = { | |||
// then just pipe them to a single unique stream and return it | |||
var aggregate = new Combine(streams); | |||
var uniqueStream = unique('path'); | |||
var returnStream = aggregate.pipe(uniqueStream); | |||
|
|||
aggregate.on('error', function (err) { |
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.
errors should propagate downstream you shouldnt need to do this afaik
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.
It seemed weird to me as well, but the tests fail without it: the error is just thrown instead of being emitted on the stream.
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.
@callumacrae 🤷 as long as it works haha, we can revisit later
Looks good, just need to tweak the error management and we are 👍 |
Emit error on file not found with singular globs
1 similar comment
Nice PR 👍 |
@contra this really should have been a 5.0 bump, not a 4.1 |
@phated Agreed. This changed build behavior here at Netflix. |
Is it worth reverting it for 4.1.1 and releasing it in 5.0? |
@callumacrae i think so |
@phated typo'd the np command, you have access to the repo and pkg - would you mind doing the revert and republish? on a plane right now and i can barely load this webpage let alone npm publish |
@contra I have publish rights but not access to this repo |
Okay published as 5.0, which means now vinyl-fs needs to be bumped to 5.0 if it wants to depend on this and then gulp needs to be updated to depend on the new vinyl-fs |
@contra were you able to publish 4.1.1 that reverts the breaking change? |
Doesn't look like it.
should do the trick. You don't need to checkout a new branch if you don't use |
np totally fails when doing this, going to have to do it manually |
Also npm unpublish is totally failing. np just published a 5.1.0 with 4.x code and now I can't unpublish it. going to have to contact npm support because everything is fucked in this toolchain |
You can't unpublish. Did you try what I said or did you start from 5.0? Because you can't do that. |
Okay all done. 4.1.1 === 4.0.1, 5.0.0 = new stuff, tagged as latest. For future reference adding --force to the end of anything makes npm work |
👍 |
Would it be possible to display the glob/filename that is causing the error? Right now it's very undescriptive and I have no idea which glob is causing the issue: Error: File not found with singular glob
at Glob.<anonymous> (/Users/Adam/Sites/meanie/boilerplate/src/node_modules/glob-stream/index.js:34:30)
at emitOne (events.js:77:13)
at Glob.emit (events.js:169:7)
at Glob._finish (/Users/Adam/Sites/meanie/boilerplate/src/node_modules/glob/glob.js:172:8)
at done (/Users/Adam/Sites/meanie/boilerplate/src/node_modules/glob/glob.js:159:12)
at Glob._processSimple2 (/Users/Adam/Sites/meanie/boilerplate/src/node_modules/glob/glob.js:652:12)
at /Users/Adam/Sites/meanie/boilerplate/src/node_modules/glob/glob.js:640:10
at Glob._stat2 (/Users/Adam/Sites/meanie/boilerplate/src/node_modules/glob/glob.js:736:12)
at lstatcb_ (/Users/Adam/Sites/meanie/boilerplate/src/node_modules/glob/glob.js:728:12)
at RES (/Users/Adam/Sites/meanie/boilerplate/src/node_modules/inflight/inflight.js:23:14)
at f (/Users/Adam/Sites/meanie/boilerplate/src/node_modules/once/once.js:17:25)
at FSReqWrap.oncomplete (fs.js:82:15) |
This is master but we aren't able to cut a release yet. |
Emit error on file not found with singular globs
Emit error on file not found with singular globs
gulpjs/gulp#374