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

Update plugin example #596

Merged
merged 7 commits into from
Dec 12, 2014
Merged

Update plugin example #596

merged 7 commits into from
Dec 12, 2014

Conversation

stephenlacy
Copy link
Contributor

  • update to through2 0.5.1 callback return
  • return through.obj

@@ -86,13 +86,11 @@ function gulpPrefixer(prefixText) {
file.contents = file.contents.pipe(prefixStream(prefixText));
}

this.push(file);
return callback();
callback(null, file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this.push(file);

putting the chunk in the callback isn't documented.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sindresorhus just put in a PR to document it on through2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@contra the callback function is from the core Streams API proxied through through2. It's not even documented in the core Streams docs. I don't have the time to look into this. But it should be documented in Node core docs before we do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sindresorhus I agree - I raised that complaint in the issue on through2, I'll PR node core as well when I have a minute

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@contra did you ever PR node core?

Lukas and others added 2 commits September 3, 2014 19:41
@phated
Copy link
Member

phated commented Sep 13, 2014

This was merged into through2 quite awhile ago. @stevelacy can you rebase for a clean merge?

@sindresorhus
Copy link
Contributor

👍 I'm using it in all my plugins and seems fine :)

@@ -74,7 +74,7 @@ function gulpPrefixer(prefixText) {
prefixText = new Buffer(prefixText); // allocate ahead of time

// Creating a stream through which each file will pass
var stream = through.obj(function(file, enc, callback) {
return through.obj(function(file, enc, callback) {
if (file.isNull()) {
// Do nothing if no contents
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be an early callback and return here to make it more clear that you should push the file even if it's null. It's also a better practise in general.

@stephenlacy
Copy link
Contributor Author

@phated I updated it.

@phated
Copy link
Member

phated commented Nov 9, 2014

Going to merge this today unless someone has issues with it.

// creating a stream through which each file will pass
var stream = through.obj(function(file, enc, cb) {
// Creating a stream through which each file will pass
return through.obj(function(file, enc, callback) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cb not callback

@yocontra
Copy link
Member

added some comments

// creating a stream through which each file will pass
var stream = through.obj(function(file, enc, cb) {
// Creating a stream through which each file will pass
return through.obj(function(file, enc, cb) {
if (file.isNull()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just skip this whole block?

yocontra pushed a commit that referenced this pull request Dec 12, 2014
@yocontra yocontra merged commit 20774cc into gulpjs:master Dec 12, 2014
@stephenlacy stephenlacy deleted the patch-1 branch December 13, 2014 01:13
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.

5 participants