Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4808abd

Browse filesBrowse files
authored
feat(progess): emit progress-update (#2498)
closes: #1666
1 parent adeb92e commit 4808abd
Copy full SHA for 4808abd

File tree

Expand file treeCollapse file tree

3 files changed

+17
-5
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+17
-5
lines changed

‎lib/Server.js

Copy file name to clipboardExpand all lines: lib/Server.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ class Server {
155155
}
156156

157157
this.sockWrite(this.sockets, 'progress-update', { percent, msg });
158+
159+
if (this.listeningApp) {
160+
this.listeningApp.emit('progress-update', { percent, msg });
161+
}
158162
}).apply(this.compiler);
159163
}
160164

‎lib/servers/WebsocketServer.js

Copy file name to clipboardExpand all lines: lib/servers/WebsocketServer.js
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ module.exports = class WebsocketServer extends BaseServer {
3131
const noop = () => {};
3232

3333
setInterval(() => {
34-
this.wsServer.clients.forEach((ws) => {
35-
if (ws.isAlive === false) return ws.terminate();
34+
this.wsServer.clients.forEach((socket) => {
35+
if (socket.isAlive === false) {
36+
return socket.terminate();
37+
}
3638

37-
ws.isAlive = false;
38-
ws.ping(noop);
39+
socket.isAlive = false;
40+
socket.ping(noop);
3941
});
4042
}, this.server.heartbeatInterval);
4143
}

‎test/server/progress-option.test.js

Copy file name to clipboardExpand all lines: test/server/progress-option.test.js
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ describe('progress', () => {
4646
});
4747

4848
compiler.run(() => {});
49-
server.listen(port, 'localhost');
49+
const app = server.listen(port, 'localhost');
50+
51+
app.on('progress-update', ({ percent, msg }) => {
52+
expect(percent).toBeGreaterThanOrEqual(0);
53+
expect(percent).toBeLessThanOrEqual(100);
54+
expect(typeof msg).toEqual('string');
55+
});
5056
});
5157
});
5258
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.