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

fix(server): Change clientLogLevel order to be called first #1973

Merged
merged 2 commits into from Jun 5, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -14,3 +14,4 @@ node_modules
.eslintcache

test/fixtures/reload-config/main.css
!/test/fixtures/contentbase-config/public/node_modules
9 changes: 5 additions & 4 deletions lib/Server.js
Expand Up @@ -694,10 +694,15 @@ class Server {
}
});

if (this.clientLogLevel) {
this.sockWrite([connection], 'log-level', this.clientLogLevel);
}

if (this.hot) {
this.sockWrite([connection], 'hot');
}

// TODO: change condition at major version
if (this.options.liveReload !== false) {
this.sockWrite([connection], 'liveReload', this.options.liveReload);
}
Expand All @@ -710,10 +715,6 @@ class Server {
this.sockWrite([connection], 'overlay', this.clientOverlay);
}

if (this.clientLogLevel) {
this.sockWrite([connection], 'log-level', this.clientLogLevel);
}

if (!this._stats) {
return;
}
Expand Down
9 changes: 7 additions & 2 deletions test/ContentBase.test.js
Expand Up @@ -68,13 +68,18 @@ describe('ContentBase', () => {
'node_modules',
'index.html'
);
fs.writeFileSync(filePath, 'foo', 'utf8');

// chokidar emitted a change,
// meaning it watched the file correctly
server.contentBaseWatchers[0].on('change', () => done());
server.contentBaseWatchers[0].on('change', () => {
fs.unlinkSync(filePath);
done();
});

// change a file manually
setTimeout(() => {
fs.writeFileSync(filePath, `${Math.random()}`, 'utf8');
fs.writeFileSync(filePath, 'bar', 'utf8');
}, 1000);
});
});
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/ClientOptions.test.js
Expand Up @@ -250,6 +250,12 @@ describe('Client console.log', () => {
liveReload: true,
},
},
{
title: 'clientLogLevel is silent',
options: {
clientLogLevel: 'silent',
},
},
];

for (const { title, options } of cases) {
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/__snapshots__/ClientOptions.test.js.snap
@@ -1,5 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Client console.log clientLogLevel is silent 1`] = `
Array [
"Hey.",
]
`;

exports[`Client console.log hot disabled 1`] = `
Array [
"Hey.",
Expand Down
Empty file.

This file was deleted.