Skip to content

Commit cf15e24

Browse files
refactor: small (#2878)
1 parent 08a83a6 commit cf15e24

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

lib/Server.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Server {
4545
this.options = options;
4646
this.logger = this.compiler.getInfrastructureLogger('webpack-dev-server');
4747
this.sockets = [];
48-
this.contentBaseWatchers = [];
48+
this.staticWatchers = [];
4949
// Keep track of websocket proxies for external websocket upgrade.
5050
this.websocketProxies = [];
5151
// this value of ws can be overwritten for tests
@@ -639,9 +639,9 @@ class Server {
639639
this.sockets = [];
640640

641641
const prom = Promise.all(
642-
this.contentBaseWatchers.map((watcher) => watcher.close())
642+
this.staticWatchers.map((watcher) => watcher.close())
643643
);
644-
this.contentBaseWatchers = [];
644+
this.staticWatchers = [];
645645

646646
this.listeningApp.kill(() => {
647647
// watchers must be closed before closing middleware
@@ -865,13 +865,15 @@ class Server {
865865
};
866866

867867
const watcher = chokidar.watch(watchPath, finalWatchOptions);
868+
868869
// disabling refreshing on changing the content
869870
if (this.options.liveReload) {
870871
watcher.on('change', () => {
871872
this.sockWrite(this.sockets, 'content-changed');
872873
});
873874
}
874-
this.contentBaseWatchers.push(watcher);
875+
876+
this.staticWatchers.push(watcher);
875877
}
876878

877879
invalidate(callback) {

test/server/liveReload-option.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('liveReload option', () => {
3737
it('Should not reload on changing files', (done) => {
3838
let reloaded = false;
3939

40-
server.contentBaseWatchers[0].on('change', () => {
40+
server.staticWatchers[0].on('change', () => {
4141
// it means that file has changed
4242

4343
// simulating server behaviour
@@ -91,7 +91,7 @@ describe('liveReload option', () => {
9191
it('Should reload on changing files', (done) => {
9292
let reloaded = false;
9393

94-
server.contentBaseWatchers[0].on('change', () => {
94+
server.staticWatchers[0].on('change', () => {
9595
// it means that files has changed
9696

9797
// simulating server behaviour

test/server/static-directory-option.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('static.directory option', () => {
5757
it('Watches folder recursively', (done) => {
5858
// chokidar emitted a change,
5959
// meaning it watched the file correctly
60-
server.contentBaseWatchers[0].on('change', () => {
60+
server.staticWatchers[0].on('change', () => {
6161
done();
6262
});
6363

@@ -73,7 +73,7 @@ describe('static.directory option', () => {
7373

7474
// chokidar emitted a change,
7575
// meaning it watched the file correctly
76-
server.contentBaseWatchers[0].on('change', () => {
76+
server.staticWatchers[0].on('change', () => {
7777
fs.unlinkSync(filePath);
7878
done();
7979
});

0 commit comments

Comments
 (0)