Skip to content

Commit fd20b91

Browse files
authoredSep 1, 2017
[test] Use npm scripts instead of gulp (#530)
1 parent 7f63d38 commit fd20b91

11 files changed

+49
-132
lines changed
 

‎.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
node_modules
22
npm-debug.log
3-
coverage.html
4-
lib-cov/
5-
dist

‎.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: node_js
33
node_js:
44
- "4"
55
- "6"
6-
- "7"
6+
- "8"
77
git:
88
depth: 1
99
notifications:

‎Makefile

-16
This file was deleted.

‎gulpfile.js

-52
This file was deleted.

‎index.js

-4
This file was deleted.

‎lib/server.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,6 @@ Server.errorMessages = {
9191

9292
util.inherits(Server, EventEmitter);
9393

94-
/**
95-
* Hash of open clients.
96-
*
97-
* @api public
98-
*/
99-
100-
Server.prototype.clients;
101-
10294
/**
10395
* Initialize websocket server
10496
*
@@ -355,7 +347,7 @@ Server.prototype.handleUpgrade = function (req, socket, upgradeHead) {
355347
return;
356348
}
357349

358-
var head = new Buffer(upgradeHead.length);
350+
var head = new Buffer(upgradeHead.length); // eslint-disable-line node/no-deprecated-api
359351
upgradeHead.copy(head);
360352
upgradeHead = null;
361353

‎lib/socket.js

-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ Socket.prototype.onPacket = function (packet) {
9191
this.setPingTimeout();
9292

9393
switch (packet.type) {
94-
9594
case 'ping':
9695
debug('got ping');
9796
this.sendPacket('pong');

‎lib/transports/polling.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Polling.prototype.onDataRequest = function (req, res) {
136136
this.dataReq = req;
137137
this.dataRes = res;
138138

139-
var chunks = isBinary ? new Buffer(0) : '';
139+
var chunks = isBinary ? new Buffer(0) : ''; // eslint-disable-line node/no-deprecated-api
140140
var self = this;
141141

142142
function cleanup () {
@@ -162,7 +162,7 @@ Polling.prototype.onDataRequest = function (req, res) {
162162
}
163163

164164
if (contentLength > self.maxHttpBufferSize) {
165-
chunks = isBinary ? new Buffer(0) : '';
165+
chunks = isBinary ? new Buffer(0) : ''; // eslint-disable-line node/no-deprecated-api
166166
req.connection.destroy();
167167
}
168168
}

‎package.json

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "engine.io",
33
"version": "3.1.0",
44
"description": "The realtime engine behind Socket.IO. Provides the foundation of a bidirectional connection between client and server",
5-
"main": "./lib/engine.io",
5+
"main": "lib/engine.io",
66
"author": "Guillermo Rauch <guillermo@learnboost.com>",
77
"homepage": "https://github.com/socketio/engine.io",
88
"contributors": [
@@ -33,17 +33,16 @@
3333
"cookie": "0.3.1"
3434
},
3535
"devDependencies": {
36-
"babel-eslint": "5.0.0",
36+
"babel-eslint": "^7.2.3",
3737
"babel-preset-es2015": "^6.24.0",
3838
"engine.io-client": "3.1.0",
39-
"eslint-config-standard": "4.4.0",
40-
"eslint-plugin-standard": "1.3.2",
39+
"eslint": "^4.5.0",
40+
"eslint-config-standard": "^10.2.1",
41+
"eslint-plugin-import": "^2.7.0",
42+
"eslint-plugin-node": "^5.1.1",
43+
"eslint-plugin-promise": "^3.5.0",
44+
"eslint-plugin-standard": "^3.0.1",
4145
"expect.js": "^0.3.1",
42-
"gulp": "^3.9.1",
43-
"gulp-babel": "^6.1.2",
44-
"gulp-eslint": "1.1.1",
45-
"gulp-mocha": "^4.3.0",
46-
"gulp-nsp": "^2.4.1",
4746
"mocha": "^3.2.0",
4847
"s": "0.1.1",
4948
"superagent": "0.15.4"
@@ -52,14 +51,14 @@
5251
"uws": "~0.14.4"
5352
},
5453
"scripts": {
55-
"test": "gulp test; EIO_WS_ENGINE=ws gulp test;"
54+
"lint": "eslint lib/ test/ *.js",
55+
"test": "npm run lint && mocha && EIO_WS_ENGINE=ws mocha"
5656
},
5757
"repository": {
5858
"type": "git",
5959
"url": "git@github.com:socketio/engine.io.git"
6060
},
6161
"files": [
62-
"index.js",
6362
"lib/"
6463
]
6564
}

‎test/jsonp.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var request = require('superagent');
1111
describe('JSONP', function () {
1212
before(function () {
1313
// we have to override the browser's functionality for JSONP
14-
document = { // eslint-disable-line no-native-reassign, no-undef
14+
document = { // eslint-disable-line no-global-assign
1515
body: {
1616
appendChild: function () {},
1717
removeChild: function () {}
@@ -44,10 +44,10 @@ describe('JSONP', function () {
4444
appendChild: function () {},
4545
submit: function () {
4646
request
47-
.post(this.action)
48-
.type('form')
49-
.send({ d: self.areaValue })
50-
.end(function () {});
47+
.post(this.action)
48+
.type('form')
49+
.send({ d: self.areaValue })
50+
.end(function () {});
5151
}
5252
};
5353
return form;
@@ -156,7 +156,7 @@ describe('JSONP', function () {
156156
});
157157

158158
it('should arrive from server to client and back with binary data (pollingJSONP)', function (done) {
159-
var binaryData = new Buffer(5);
159+
var binaryData = Buffer.allocUnsafe(5);
160160
for (var i = 0; i < 5; i++) binaryData[i] = i;
161161
engine.on('connection', function (conn) {
162162
conn.on('message', function (msg) {
@@ -178,7 +178,7 @@ describe('JSONP', function () {
178178
it('should trigger when server closes a client', function (done) {
179179
var engine = listen({ allowUpgrades: false, transports: ['polling'] }, function (port) {
180180
var socket = new eioc.Socket('ws://localhost:' + port,
181-
{ transports: ['polling'], forceJSONP: true, upgrade: false });
181+
{ transports: ['polling'], forceJSONP: true, upgrade: false });
182182
var total = 2;
183183

184184
engine.on('connection', function (conn) {

‎test/server.js

+28-26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable standard/no-callback-literal */
12

23
/**
34
* Tests dependencies.
@@ -352,18 +353,18 @@ describe('server', function () {
352353
var socket = new eioc.Socket('ws://localhost:%d'.s(port));
353354
socket.on('open', function () {
354355
request.get('http://localhost:%d/engine.io/'.s(port))
355-
.set({ connection: 'close' })
356-
.query({ transport: 'websocket', sid: socket.id })
357-
.end(function (err, res) {
358-
expect(err).to.be(null);
359-
expect(res.status).to.be(400);
360-
expect(res.body.code).to.be(3);
361-
socket.send('echo');
362-
socket.on('message', function (msg) {
363-
expect(msg).to.be('echo');
364-
done();
356+
.set({ connection: 'close' })
357+
.query({ transport: 'websocket', sid: socket.id })
358+
.end(function (err, res) {
359+
expect(err).to.be(null);
360+
expect(res.status).to.be(400);
361+
expect(res.body.code).to.be(3);
362+
socket.send('echo');
363+
socket.on('message', function (msg) {
364+
expect(msg).to.be('echo');
365+
done();
366+
});
365367
});
366-
});
367368
});
368369
});
369370
});
@@ -1353,7 +1354,7 @@ describe('server', function () {
13531354
});
13541355

13551356
it('should arrive when binary data is sent as Buffer (ws)', function (done) {
1356-
var binaryData = new Buffer(5);
1357+
var binaryData = Buffer.allocUnsafe(5);
13571358
for (var i = 0; i < binaryData.length; i++) {
13581359
binaryData.writeInt8(i, i);
13591360
}
@@ -1379,7 +1380,7 @@ describe('server', function () {
13791380
});
13801381

13811382
it('should arrive when binary data sent as Buffer (polling)', function (done) {
1382-
var binaryData = new Buffer(5);
1383+
var binaryData = Buffer.allocUnsafe(5);
13831384
for (var i = 0; i < binaryData.length; i++) {
13841385
binaryData.writeInt8(i, i);
13851386
}
@@ -1406,7 +1407,7 @@ describe('server', function () {
14061407
});
14071408

14081409
it('should arrive as ArrayBuffer if requested when binary data sent as Buffer (ws)', function (done) {
1409-
var binaryData = new Buffer(5);
1410+
var binaryData = Buffer.allocUnsafe(5);
14101411
for (var i = 0; i < binaryData.length; i++) {
14111412
binaryData.writeInt8(i, i);
14121413
}
@@ -1435,7 +1436,7 @@ describe('server', function () {
14351436
});
14361437

14371438
it('should arrive as ArrayBuffer if requested when binary data sent as Buffer (polling)', function (done) {
1438-
var binaryData = new Buffer(5);
1439+
var binaryData = Buffer.allocUnsafe(5);
14391440
for (var i = 0; i < binaryData.length; i++) {
14401441
binaryData.writeInt8(i, i);
14411442
}
@@ -1516,8 +1517,8 @@ describe('server', function () {
15161517
var socket = new eioc.Socket('ws://localhost:%d'.s(port), { transports: ['websocket'] });
15171518
socket.on('open', function () {
15181519
for (var i = 0; i < messageCount; i++) {
1519-
// connection.send('message: ' + i); // works
1520-
connection.send(messagePayload + '|message: ' + i); // does not work
1520+
// connection.send('message: ' + i); // works
1521+
connection.send(messagePayload + '|message: ' + i); // does not work
15211522
}
15221523
var receivedCount = 0;
15231524
socket.on('message', function (msg) {
@@ -1614,7 +1615,8 @@ describe('server', function () {
16141615
key: fs.readFileSync('test/fixtures/server.key'),
16151616
cert: fs.readFileSync('test/fixtures/server.crt'),
16161617
ca: fs.readFileSync('test/fixtures/ca.crt'),
1617-
requestCert: true
1618+
requestCert: true,
1619+
rejectUnauthorized: false
16181620
};
16191621

16201622
var opts = {
@@ -2309,7 +2311,7 @@ describe('server', function () {
23092311
it('should compress by default', function (done) {
23102312
var engine = listen({ transports: ['polling'] }, function (port) {
23112313
engine.on('connection', function (conn) {
2312-
var buf = new Buffer(1024);
2314+
var buf = Buffer.allocUnsafe(1024);
23132315
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
23142316
conn.send(buf);
23152317
});
@@ -2337,7 +2339,7 @@ describe('server', function () {
23372339
it('should compress using deflate', function (done) {
23382340
var engine = listen({ transports: ['polling'] }, function (port) {
23392341
engine.on('connection', function (conn) {
2340-
var buf = new Buffer(1024);
2342+
var buf = Buffer.allocUnsafe(1024);
23412343
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
23422344
conn.send(buf);
23432345
});
@@ -2365,7 +2367,7 @@ describe('server', function () {
23652367
it('should set threshold', function (done) {
23662368
var engine = listen({ transports: ['polling'], httpCompression: { threshold: 0 } }, function (port) {
23672369
engine.on('connection', function (conn) {
2368-
var buf = new Buffer(10);
2370+
var buf = Buffer.allocUnsafe(10);
23692371
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
23702372
conn.send(buf);
23712373
});
@@ -2390,7 +2392,7 @@ describe('server', function () {
23902392
it('should disable compression', function (done) {
23912393
var engine = listen({ transports: ['polling'], httpCompression: false }, function (port) {
23922394
engine.on('connection', function (conn) {
2393-
var buf = new Buffer(1024);
2395+
var buf = Buffer.allocUnsafe(1024);
23942396
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
23952397
conn.send(buf);
23962398
});
@@ -2415,7 +2417,7 @@ describe('server', function () {
24152417
it('should disable compression per message', function (done) {
24162418
var engine = listen({ transports: ['polling'] }, function (port) {
24172419
engine.on('connection', function (conn) {
2418-
var buf = new Buffer(1024);
2420+
var buf = Buffer.allocUnsafe(1024);
24192421
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
24202422
conn.send(buf, { compress: false });
24212423
});
@@ -2440,7 +2442,7 @@ describe('server', function () {
24402442
it('should not compress when the byte size is below threshold', function (done) {
24412443
var engine = listen({ transports: ['polling'] }, function (port) {
24422444
engine.on('connection', function (conn) {
2443-
var buf = new Buffer(100);
2445+
var buf = Buffer.allocUnsafe(100);
24442446
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
24452447
conn.send(buf);
24462448
});
@@ -2478,7 +2480,7 @@ describe('server', function () {
24782480
done();
24792481
};
24802482

2481-
var buf = new Buffer(100);
2483+
var buf = Buffer.allocUnsafe(100);
24822484
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
24832485
conn.send(buf, { compress: true });
24842486
});
@@ -2500,7 +2502,7 @@ describe('server', function () {
25002502
done();
25012503
};
25022504

2503-
var buf = new Buffer(100);
2505+
var buf = Buffer.allocUnsafe(100);
25042506
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
25052507
conn.send(buf, { compress: true });
25062508
});

0 commit comments

Comments
 (0)
Please sign in to comment.