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

Adjust on stream #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ var nightwatchPlugin = function(options) {
child.kill();
}

if (stream) {
if(options.abortOnFailure === true && stream) {
if (code) {
stream.emit('error', new PluginError(PLUGIN_NAME, 'nightwatch exited with code ' + code));
} else {
stream.emit('end');
}
} else {
stream.emit('end');
Copy link
Owner

Choose a reason for hiding this comment

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

I think when stream is undefined, calling stream.emit fails.

How about the following code:

if (stream) {
  if (options.abortOnFailure) {
     stream.emit('end');
  } else if (code) {
     stream.emit('error', new PluginError(PLUGIN_NAME, 'nightwatch exited with code ' + code));
  } else {
     stream.emit('end');
  } 
}

Copy link
Author

Choose a reason for hiding this comment

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

That's right, I did the reverse.
False by default, it issues End of Error instead.

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, the above code I wrote is wrong...
The below code is a correct example:

if (stream) {
  if (code && options.abortOnFailure) {
     stream.emit('error', new PluginError(PLUGIN_NAME, 'nightwatch exited with code ' + code));
  } else {
     stream.emit('end');
  } 
}

I think when stream is undefined, calling stream.emit fails.

I care about that if options.abortOnFailure is true and stream is undefined at the line 37 condition, Uncaught TypeError: Cannot read property 'emit' of undefined occurs at the line 44.

gulp-nightwatch/index.js

Lines 37 to 45 in dddef70

if(options.abortOnFailure === true && stream) {
if (code) {
stream.emit('error', new PluginError(PLUGIN_NAME, 'nightwatch exited with code ' + code));
} else {
stream.emit('end');
}
} else {
stream.emit('end');
}

}
}

Expand Down