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

Commit

Permalink
Fix #532, Fix #566, add tslint in ci, add tslint/format/test/karma in…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
JiaLiPassion authored and mhevery committed Jan 12, 2017
1 parent ecbef87 commit fb8d51c
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ before_script:
- ./scripts/sauce/sauce_connect_block.sh

script:
- node_modules/.bin/gulp lint
- node_modules/.bin/gulp format:enforce
- node_modules/.bin/gulp build
- node_modules/.bin/karma start karma-dist-sauce-jasmine.conf.js --single-run
Expand Down
34 changes: 34 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,37 @@ Run the browser tests using Karma:
Run the node.js tests:

`npm run test-node`

Run tslint:

`npm run lint`

Run format with clang-format:

`npm run format`

Run all checks (lint/format/browser test/test-node):

`npm run ci`

Before Commit
------------

Please make sure you pass all following checks before commit

- tslint
- format:enforce (clang-format)
- npm test (karma test)
- test-node (node test)

You can run

`npm run ci`

to do all those checks for you.
You can also add the script into your git pre-commit hook

```
echo -e 'exec npm run ci' > .git/hooks/pre-commit
chmod u+x .git/hooks/pre-commit
```
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@
},
"scripts": {
"changelog": "gulp changelog",
"ci": "npm run lint && npm run format && npm run test:single && npm run test-node",
"format": "gulp format:enforce",
"karma-jasmine": "karma start karma-build-jasmine.conf.js",
"karma-jasmine:single": "karma start karma-build-jasmine.conf.js --single-run",
"karma-jasmine:autoclose": "npm run karma-jasmine:single && npm run ws-client",
"lint": "gulp lint",
"prepublish": "tsc && gulp build",
"ws-client": "node ./test/ws-client.js",
"ws-server": "node ./test/ws-server.js",
"tsc": "tsc",
"tsc:w": "tsc -w",
"test": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-build-jasmine.conf.js\"",
"test": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine\"",
"test:single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine:autoclose\"",
"test-dist": "concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-dist-jasmine.conf.js\"",
"test-node": "gulp test/node",
"test-mocha": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-build-mocha.conf.js\"",
Expand Down
14 changes: 14 additions & 0 deletions test/ws-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

const ws = require('nodejs-websocket');

const conn = ws.connect('ws://localhost:8001', {}, function() {
conn.send('close');
conn.close();
});
8 changes: 6 additions & 2 deletions test/ws-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/

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

// simple echo server
ws.createServer(function (conn) {
const server = ws.createServer(function (conn) {
conn.on('text', function (str) {
if (str === 'close') {
server.close();
return;
}
conn.sendText(str.toString());
});
}).listen(8001);

0 comments on commit fb8d51c

Please sign in to comment.