Skip to content

Commit 57c8c92

Browse files
authored
fix(server): Change clientLogLevel order to be called first (#1973)
* fix(server): change clientLogLevel order to be called first * test: fix contentbase tests
1 parent 9582418 commit 57c8c92

File tree

7 files changed

+25
-7
lines changed

7 files changed

+25
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ node_modules
1414
.eslintcache
1515

1616
test/fixtures/reload-config/main.css
17+
!/test/fixtures/contentbase-config/public/node_modules

lib/Server.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,15 @@ class Server {
694694
}
695695
});
696696

697+
if (this.clientLogLevel) {
698+
this.sockWrite([connection], 'log-level', this.clientLogLevel);
699+
}
700+
697701
if (this.hot) {
698702
this.sockWrite([connection], 'hot');
699703
}
700704

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

713-
if (this.clientLogLevel) {
714-
this.sockWrite([connection], 'log-level', this.clientLogLevel);
715-
}
716-
717718
if (!this._stats) {
718719
return;
719720
}

test/ContentBase.test.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,18 @@ describe('ContentBase', () => {
6868
'node_modules',
6969
'index.html'
7070
);
71+
fs.writeFileSync(filePath, 'foo', 'utf8');
72+
7173
// chokidar emitted a change,
7274
// meaning it watched the file correctly
73-
server.contentBaseWatchers[0].on('change', () => done());
75+
server.contentBaseWatchers[0].on('change', () => {
76+
fs.unlinkSync(filePath);
77+
done();
78+
});
7479

7580
// change a file manually
7681
setTimeout(() => {
77-
fs.writeFileSync(filePath, `${Math.random()}`, 'utf8');
82+
fs.writeFileSync(filePath, 'bar', 'utf8');
7883
}, 1000);
7984
});
8085
});

test/e2e/ClientOptions.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ describe('Client console.log', () => {
250250
liveReload: true,
251251
},
252252
},
253+
{
254+
title: 'clientLogLevel is silent',
255+
options: {
256+
clientLogLevel: 'silent',
257+
},
258+
},
253259
];
254260

255261
for (const { title, options } of cases) {

test/e2e/__snapshots__/ClientOptions.test.js.snap

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`Client console.log clientLogLevel is silent 1`] = `
4+
Array [
5+
"Hey.",
6+
]
7+
`;
8+
39
exports[`Client console.log hot disabled 1`] = `
410
Array [
511
"Hey.",

test/fixtures/contentbase-config/public/node_modules/.gitkeep

Whitespace-only changes.

test/fixtures/contentbase-config/public/node_modules/index.html

-1
This file was deleted.

0 commit comments

Comments
 (0)