Skip to content

Commit

Permalink
fix(server): Change clientLogLevel order to be called first (#1973)
Browse files Browse the repository at this point in the history
* fix(server): change clientLogLevel order to be called first

* test: fix contentbase tests
  • Loading branch information
hiroppy committed Jun 5, 2019
1 parent 9582418 commit 57c8c92
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
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.

0 comments on commit 57c8c92

Please sign in to comment.