Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ npm-debug.log
coverage
node_modules
.eslintcache
.idea

test/**/output*
output.js
Expand Down
5 changes: 3 additions & 2 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ const setupRoutes = function setupRoutes() {
socket.lastHash = hash;

const { errors = [], warnings = [] } = stats.toJson(statsOptions);
const hasErrors = Boolean(errors.length);
Copy link
Owner

Choose a reason for hiding this comment

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

curious about this assertion. we're only in need of a truthy/falsy value here. was there an explicit need to case to Boolean?

Copy link
Author

@artembatura artembatura Feb 4, 2019

Choose a reason for hiding this comment

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

Yeah, this doesn't change much using Boolean. It's more stricter perhaps ^o^
And next I simply reuse value

Instead of this:

if (errors.length || warnings.length) {
  ...
  if (errors.length) return;
}

I written:

const hasErrors = Boolean(errors.length);
if (hasErrors  || warnings.length) {
  ...
  if (hasErrors) return;
}


if (errors.length || warnings.length) {
if (hasErrors || warnings.length) {
socket.send(
prep({
action: 'problems',
Expand All @@ -60,7 +61,7 @@ const setupRoutes = function setupRoutes() {
})
);

return;
if (hasErrors) return;
}

if (options.hmr || options.liveReload) {
Expand Down