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

Adjust on stream #60

wants to merge 1 commit into from

Conversation

dgateles
Copy link

@dgateles dgateles commented Jun 5, 2019

Prevent gulp stops execution when test abort. New option: abortOnFailure(bool).

Prevent gulp stops execution when test abort. New option: abortOnFailure(bool).
Copy link
Owner

@tatsuyafw tatsuyafw left a comment

Choose a reason for hiding this comment

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

@dgateles

Thanks for this PR!
I would be glad if you also update the README.

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');
}

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.

2 participants