wait-for-localhost
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -22,2 +22,9 @@ export interface Options { | ||
useGet?: boolean; | ||
/** | ||
HTTP status codes to consider as successful responses. | ||
@default [200] | ||
*/ | ||
statusCodes?: readonly number[]; | ||
} | ||
@@ -24,0 +31,0 @@ |
import http from 'node:http'; | ||
export default function waitForLocalhost({port, path, useGet} = {}) { | ||
export default function waitForLocalhost({port, path, useGet, statusCodes = [200]} = {}) { | ||
return new Promise(resolve => { | ||
@@ -13,3 +13,3 @@ const retry = () => { | ||
const request = http.request({method, port, path, family: ipVersion}, response => { | ||
if (response.statusCode === 200) { | ||
if (statusCodes.includes(response.statusCode)) { | ||
resolve({ipVersion}); | ||
@@ -16,0 +16,0 @@ return; |
{ | ||
"name": "wait-for-localhost", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Wait for localhost to be ready", | ||
@@ -15,2 +15,4 @@ "license": "MIT", | ||
"exports": "./index.js", | ||
"types": "./index.d.ts", | ||
"sideEffects": false, | ||
"engines": { | ||
@@ -17,0 +19,0 @@ "node": "^12.20.0 || ^14.13.1 || >=16.0.0" |
@@ -55,2 +55,9 @@ # wait-for-localhost | ||
##### statusCodes | ||
Type: `number[]`\ | ||
Default: `[200]` | ||
HTTP status codes to consider as successful responses. | ||
## Related | ||
@@ -57,0 +64,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
4539
60
66