start-server-and-test
Advanced tools
Comparing version 1.4.1 to 1.5.0
{ | ||
"name": "start-server-and-test", | ||
"description": "Starts server, waits for URL, then runs test command; when the tests end, shuts down server", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
@@ -78,3 +78,5 @@ "bugs": "https://github.com/bahmutov/start-server-and-test/issues", | ||
"start-with-child": "node test/server-as-child.js", | ||
"start-multiple": "node test/multiple-servers.js", | ||
"test2": "curl http://127.0.0.1:9000", | ||
"test3": "curl http://127.0.0.1:9000 && curl http://127.0.0.1:9001", | ||
"demo": "node bin/start.js http://127.0.0.1:9000", | ||
@@ -87,2 +89,3 @@ "demo2": "node bin/start.js start http://127.0.0.1:9000 test2", | ||
"demo7": "node bin/start.js :9000 test2", | ||
"demo8": "node bin/start.js start-multiple \":9000|:9001\" test3", | ||
"travis-deploy-once": "travis-deploy-once" | ||
@@ -93,11 +96,11 @@ }, | ||
"dependency-check": "3.1.0", | ||
"deps-ok": "1.4.0", | ||
"deps-ok": "1.4.1", | ||
"dont-crack": "1.2.1", | ||
"git-issues": "1.3.1", | ||
"license-checker": "18.0.0", | ||
"mocha": "5.0.5", | ||
"license-checker": "20.1.0", | ||
"mocha": "5.2.0", | ||
"nsp": "3.2.1", | ||
"pre-git": "3.17.1", | ||
"prettier-standard": "8.0.1", | ||
"semantic-release": "15.1.5", | ||
"semantic-release": "15.6.0", | ||
"simple-commit-message": "4.0.3", | ||
@@ -104,0 +107,0 @@ "standard": "11.0.1", |
@@ -101,2 +101,14 @@ # start-server-and-test | ||
You can provide multiple resources to wait on, separated by a pipe `|`. _(be sure to wrap in quotes)_ | ||
```json | ||
{ | ||
"scripts": { | ||
"start": "npm start", | ||
"test-it": "mocha e2e-spec.js", | ||
"ci": "server-test \"8080|http://foo.com\"" | ||
} | ||
} | ||
``` | ||
## Note for webpack-dev-server users | ||
@@ -103,0 +115,0 @@ |
@@ -17,3 +17,7 @@ 'use strict' | ||
la(is.unemptyString(test), 'missing test script name', test) | ||
la(is.unemptyString(url), 'missing url to wait on', url) | ||
la( | ||
is.unemptyString(url) || is.unemptyArray(url), | ||
'missing url to wait on', | ||
url | ||
) | ||
@@ -47,3 +51,3 @@ debug('starting server, verbose mode?', isDebug()) | ||
{ | ||
resources: [url], | ||
resources: Array.isArray(url) ? url : [url], | ||
interval: 2000, | ||
@@ -50,0 +54,0 @@ window: 1000, |
const is = require('check-more-types') | ||
const isUrlOrPort = s => { | ||
if (is.url(s)) { | ||
return s | ||
} | ||
if (is.number(s)) { | ||
return is.port(s) | ||
} | ||
if (!is.string(s)) { | ||
return false | ||
} | ||
if (s[0] === ':') { | ||
const withoutColon = s.substr(1) | ||
return is.port(parseInt(withoutColon)) | ||
} | ||
return is.port(parseInt(s)) | ||
const isUrlOrPort = input => { | ||
const str = is.string(input) ? input.split('|') : [input] | ||
return str.every(s => { | ||
if (is.url(s)) { | ||
return s | ||
} | ||
if (is.number(s)) { | ||
return is.port(s) | ||
} | ||
if (!is.string(s)) { | ||
return false | ||
} | ||
if (s[0] === ':') { | ||
const withoutColon = s.substr(1) | ||
return is.port(parseInt(withoutColon)) | ||
} | ||
return is.port(parseInt(s)) | ||
}) | ||
} | ||
const normalizeUrl = s => { | ||
if (is.url(s)) { | ||
return s | ||
} | ||
const normalizeUrl = input => { | ||
const str = is.string(input) ? input.split('|') : [input] | ||
if (is.number(s) && is.port(s)) { | ||
return `http://localhost:${s}` | ||
} | ||
return str.map(s => { | ||
if (is.url(s)) { | ||
return s | ||
} | ||
if (!is.string(s)) { | ||
return s | ||
} | ||
if (is.number(s) && is.port(s)) { | ||
return `http://localhost:${s}` | ||
} | ||
if (is.port(parseInt(s))) { | ||
return `http://localhost:${s}` | ||
} | ||
if (!is.string(s)) { | ||
return s | ||
} | ||
if (s[0] === ':') { | ||
return `http://localhost${s}` | ||
} | ||
// for anything else, return original argument | ||
return s | ||
if (is.port(parseInt(s))) { | ||
return `http://localhost:${s}` | ||
} | ||
if (s[0] === ':') { | ||
return `http://localhost${s}` | ||
} | ||
// for anything else, return original argument | ||
return s | ||
}) | ||
} | ||
@@ -43,0 +51,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13644
153
177