Skip to content

Commit 39500da

Browse files
committed
feat: allow <port> <test command> shortcut, close #27
1 parent ddbbc43 commit 39500da

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ script:
1717
- npm run demo4
1818
- npm run demo5
1919
- npm run demo6
20+
- npm run demo7
2021
after_success:
2122
- npm run travis-deploy-once "npm run semantic-release"
2223
branches:

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ To execute all tests simply run `npm run ci`
3737

3838
You can use either `start-server-and-test` or `server-test` commands in your scripts.
3939

40+
You can use `:` in front of port number like `server-test :8080`.
41+
4042
### Options
4143

4244
If you use convention and name your scripts "start" and "test" you can simply provide URL
@@ -75,6 +77,18 @@ You can provide first start command, port (or url) and implicit `test` command
7577
}
7678
```
7779

80+
You can provide port number and custom test command, in that case `npm start` is assumed to start the server.
81+
82+
```json
83+
{
84+
"scripts": {
85+
"start": "npm start",
86+
"test-it": "mocha e2e-spec.js",
87+
"ci": "server-test :9000 test-it"
88+
}
89+
}
90+
```
91+
7892
## Note for webpack-dev-server users
7993

8094
If you are using [webpack-dev-server](https://www.npmjs.com/package/webpack-dev-server) (directly or via `angular/cli` or other boilerplates) then please use the following URL form to check

bin/start.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,19 @@ if (args.length === 1 && utils.isUrlOrPort(args[0])) {
1313
// passed just single url or port number, for example
1414
// "start": "http://localhost:8080"
1515
url = utils.normalizeUrl(args[0])
16-
} else if (args.length === 2 && utils.isUrlOrPort(args[1])) {
17-
// passed start command and url/port
18-
// like "start-server 8080"
19-
start = args[0]
20-
url = utils.normalizeUrl(args[1])
16+
} else if (args.length === 2) {
17+
if (utils.isUrlOrPort(args[0])) {
18+
// passed port and custom test command
19+
// like ":8080 test-ci"
20+
url = utils.normalizeUrl(args[0])
21+
test = args[1]
22+
}
23+
if (utils.isUrlOrPort(args[1])) {
24+
// passed start command and url/port
25+
// like "start-server 8080"
26+
start = args[0]
27+
url = utils.normalizeUrl(args[1])
28+
}
2129
} else {
2230
la(args.length === 3, 'expect: <start script name> <url> <test script name>')
2331
start = args[0]

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"demo4": "node bin/start.js 9000",
8282
"demo5": "node bin/start.js start-with-child 9000",
8383
"demo6": "node bin/start.js :9000",
84+
"demo7": "node bin/start.js :9000 test2",
8485
"travis-deploy-once": "travis-deploy-once"
8586
},
8687
"devDependencies": {

0 commit comments

Comments
 (0)