Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit fb8d51c

Browse files
JiaLiPassionmhevery
authored andcommitted
Fix #532, Fix #566, add tslint in ci, add tslint/format/test/karma in precommit of git (#565)
* fix #532, add tslint in ci, add tslint/karma/testnode/format in git commit hook * fix #532, add tslint in ci, add tslint/karma/testnode/format in git commit hook * use format:enforce * rename package.json script's name * update developer.md to add precommit details * change var to const * add scripts explaination into DEVELOPER.md, use gulp lint * remove pre-commit hooks * update DEVELOPER.md to add process for before commit * format DEVELOPMER.md
1 parent ecbef87 commit fb8d51c

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

Diff for: .travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ before_script:
2222
- ./scripts/sauce/sauce_connect_block.sh
2323

2424
script:
25+
- node_modules/.bin/gulp lint
2526
- node_modules/.bin/gulp format:enforce
2627
- node_modules/.bin/gulp build
2728
- node_modules/.bin/karma start karma-dist-sauce-jasmine.conf.js --single-run

Diff for: DEVELOPER.md

+34
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,37 @@ Run the browser tests using Karma:
2323
Run the node.js tests:
2424

2525
`npm run test-node`
26+
27+
Run tslint:
28+
29+
`npm run lint`
30+
31+
Run format with clang-format:
32+
33+
`npm run format`
34+
35+
Run all checks (lint/format/browser test/test-node):
36+
37+
`npm run ci`
38+
39+
Before Commit
40+
------------
41+
42+
Please make sure you pass all following checks before commit
43+
44+
- tslint
45+
- format:enforce (clang-format)
46+
- npm test (karma test)
47+
- test-node (node test)
48+
49+
You can run
50+
51+
`npm run ci`
52+
53+
to do all those checks for you.
54+
You can also add the script into your git pre-commit hook
55+
56+
```
57+
echo -e 'exec npm run ci' > .git/hooks/pre-commit
58+
chmod u+x .git/hooks/pre-commit
59+
```

Diff for: package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@
1515
},
1616
"scripts": {
1717
"changelog": "gulp changelog",
18+
"ci": "npm run lint && npm run format && npm run test:single && npm run test-node",
19+
"format": "gulp format:enforce",
20+
"karma-jasmine": "karma start karma-build-jasmine.conf.js",
21+
"karma-jasmine:single": "karma start karma-build-jasmine.conf.js --single-run",
22+
"karma-jasmine:autoclose": "npm run karma-jasmine:single && npm run ws-client",
23+
"lint": "gulp lint",
1824
"prepublish": "tsc && gulp build",
25+
"ws-client": "node ./test/ws-client.js",
1926
"ws-server": "node ./test/ws-server.js",
2027
"tsc": "tsc",
2128
"tsc:w": "tsc -w",
22-
"test": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-build-jasmine.conf.js\"",
29+
"test": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine\"",
30+
"test:single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine:autoclose\"",
2331
"test-dist": "concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-dist-jasmine.conf.js\"",
2432
"test-node": "gulp test/node",
2533
"test-mocha": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-build-mocha.conf.js\"",

Diff for: test/ws-client.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
const ws = require('nodejs-websocket');
10+
11+
const conn = ws.connect('ws://localhost:8001', {}, function() {
12+
conn.send('close');
13+
conn.close();
14+
});

Diff for: test/ws-server.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
var ws = require('nodejs-websocket');
9+
const ws = require('nodejs-websocket');
1010

1111
// simple echo server
12-
ws.createServer(function (conn) {
12+
const server = ws.createServer(function (conn) {
1313
conn.on('text', function (str) {
14+
if (str === 'close') {
15+
server.close();
16+
return;
17+
}
1418
conn.sendText(str.toString());
1519
});
1620
}).listen(8001);

0 commit comments

Comments
 (0)