Skip to content

Adjust on stream#60

Open
dgateles wants to merge 1 commit intotatsuyafw:masterfrom
dgateles:patch-1
Open

Adjust on stream#60
dgateles wants to merge 1 commit intotatsuyafw:masterfrom
dgateles:patch-1

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.

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