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

Emit error on file not found with singular globs #41

Merged
merged 8 commits into from Mar 16, 2015

Conversation

callumacrae
Copy link
Member

should.fail();
});

// For some reason `end` isn't called unless `data` is first?
Copy link
Member Author

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).

Copy link
Member

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

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.25%) to 98.75% when pulling 4eacfeb on callumacrae:empty-error into 6411ea4 on wearefractal:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 7c321c5 on callumacrae:empty-error into 6411ea4 on wearefractal:master.

if (positives.length === 1) {
return streamFromPositive(positives[0]);
} else {
opt.allowEmpty = true;
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member Author

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?

Copy link
Member

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.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 0216b07 on callumacrae:empty-error into 6411ea4 on wearefractal:master.

@yocontra
Copy link
Member

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();
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling e139649 on callumacrae:empty-error into 6411ea4 on wearefractal:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling f9e7bd8 on callumacrae:empty-error into 6411ea4 on wearefractal:master.

@callumacrae
Copy link
Member Author

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

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 match event doesn't say which glob was matched.

@yocontra
Copy link
Member

@callumacrae Any direct path should fail if it wasn't found, only doing so when one is specified seems like the unintuitive route

@yocontra
Copy link
Member

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

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 006467f on callumacrae:empty-error into 6411ea4 on wearefractal:master.

@callumacrae
Copy link
Member Author

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) {
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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

@yocontra
Copy link
Member

Looks good, just need to tweak the error management and we are 👍

yocontra pushed a commit that referenced this pull request Mar 16, 2015
Emit error on file not found with singular globs
@yocontra yocontra merged commit fac7fa8 into gulpjs:master Mar 16, 2015
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling e777792 on callumacrae:empty-error into 6411ea4 on wearefractal:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling e777792 on callumacrae:empty-error into 6411ea4 on wearefractal:master.

@armandabric
Copy link

Nice PR 👍

@callumacrae callumacrae deleted the empty-error branch March 16, 2015 17:42
@phated
Copy link
Member

phated commented Mar 17, 2015

@contra this really should have been a 5.0 bump, not a 4.1

@jameswomack
Copy link

@phated Agreed. This changed build behavior here at Netflix.

@callumacrae
Copy link
Member Author

Is it worth reverting it for 4.1.1 and releasing it in 5.0?

@phated
Copy link
Member

phated commented Mar 17, 2015

@callumacrae i think so

@yocontra
Copy link
Member

@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

@phated
Copy link
Member

phated commented Mar 17, 2015

@contra I have publish rights but not access to this repo

@yocontra
Copy link
Member

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

@phated
Copy link
Member

phated commented Mar 19, 2015

@contra were you able to publish 4.1.1 that reverts the breaking change?

@callumacrae
Copy link
Member Author

npm ERR! version not found: glob-stream@4.1.1

Doesn't look like it.

git checkout fac7fa8957867e7b1348261118b18185b09e5218^
git checkout -b 4.x
np
npm dist-tag add glob-stream@5.0.0 latest

should do the trick. You don't need to checkout a new branch if you don't use np.

@yocontra
Copy link
Member

np totally fails when doing this, going to have to do it manually

@yocontra
Copy link
Member

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

@callumacrae
Copy link
Member Author

You can't unpublish. Did you try what I said or did you start from 5.0? Because you can't do that.

@yocontra
Copy link
Member

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

@callumacrae
Copy link
Member Author

👍

@adamreisnz
Copy link

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)

@phated
Copy link
Member

phated commented Nov 4, 2015

This is master but we aren't able to cut a release yet.

phated pushed a commit that referenced this pull request Feb 16, 2017
Emit error on file not found with singular globs
phated pushed a commit that referenced this pull request Feb 16, 2017
Emit error on file not found with singular globs
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.

None yet

7 participants