Socket
Socket
Sign inDemoInstall

wait-on

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wait-on - npm Package Compare versions

Comparing version 1.1.3 to 1.2.0

17

bin/usage.txt

@@ -18,9 +18,12 @@ Usage: wait-on {OPTIONS} resource [...resource]

file: - regular file (also default type). ex: file:/path/to/file
http: - HTTP HEAD returns 2XX response. ex: http://m.com:90/foo
https: - HTTPS HEAD returns 2XX response. ex: https://my/bar
tcp: - TCP port is listening. ex: 1.2.3.4:9000 or foo.com:700
socket: - Domain Socket is listening. ex: socket:/path/to/sock
For http over socket, use http://unix:SOCK_PATH:URL_PATH
like http://unix:/path/to/sock:/foo/bar
file: - regular file (also default type). ex: file:/path/to/file
http: - HTTP HEAD returns 2XX response. ex: http://m.com:90/foo
https: - HTTPS HEAD returns 2XX response. ex: https://my/bar
http-get: - HTTP GET returns 2XX response. ex: http://m.com:90/foo
https-get: - HTTPS GET returns 2XX response. ex: https://my/bar
tcp: - TCP port is listening. ex: 1.2.3.4:9000 or foo.com:700
socket: - Domain Socket is listening. ex: socket:/path/to/sock
For http over socket, use http://unix:SOCK_PATH:URL_PATH
like http://unix:/path/to/sock:/foo/bar or
http-get://unix:/path/to/sock:/foo/bar

@@ -27,0 +30,0 @@ Standard Options:

@@ -12,2 +12,3 @@ 'use strict';

var head = Rx.Observable.fromNodeCallback(Request.head);
var get = Rx.Observable.fromNodeCallback(Request.get);

@@ -32,2 +33,4 @@ var WAIT_ON_SCHEMA = Joi.object().keys({

- https://my.bar.com/cat verifies HTTPS HEAD request returns 2XX
- http-get: - HTTP GET returns 2XX response. ex: http://m.com:90/foo
- https-get: - HTTPS GET returns 2XX response. ex: https://my/bar
- tcp:my.server.com:3000 verifies a service is listening on port

@@ -149,4 +152,8 @@ - socket:/path/sock verifies a service is listening on (UDS) socket

return createHttp$(resource);
} else if (resource.startsWith('http-get:')) {
return createHttpGet$('http:' + resource.slice('http-get:'.length));
} else if (resource.startsWith('https:')) {
return createHttp$(resource);
} else if (resource.startsWith('https-get:')) {
return createHttpGet$('https:' + resource.slice('https-get:'.length));
} else if (resource.startsWith('tcp:')) {

@@ -195,2 +202,21 @@ return createTcp$(resource.slice('tcp:'.length));

function createHttpGet$(url) {
return Rx.Observable.catch(
get(url),
Rx.Observable.just([{statusCode: 999}])
)
.map(function (response) {
// Why is response in array here?
var statusCode = response[0].statusCode;
return {
// request will handle redirects before returning
// anything but 2XX is a failure
val: (statusCode >= 200 && statusCode <= 299) ?
statusCode :
-1 * statusCode,
data: response[0]
};
});
}
function createTcp$(hostAndPort) {

@@ -197,0 +223,0 @@ var arrParts = hostAndPort.split(':');

{
"name": "wait-on",
"version": "1.1.3",
"version": "1.2.0",
"dependencies": {

@@ -5,0 +5,0 @@ "core-js": {

{
"name": "wait-on",
"description": "wait-on is a cross platform command line utility and Node.js API which will wait for files, ports, sockets, and http(s) resources to become available",
"version": "1.1.3",
"version": "1.2.0",
"main": "lib/wait-on",

@@ -6,0 +6,0 @@ "bin": {

@@ -7,3 +7,3 @@ # wait-on - wait for files, ports, sockets, http(s) resources

For http(s) resources wait-on will check that the requests are returning 2XX (success) to HEAD requests (after following any redirects).
For http(s) resources wait-on will check that the requests are returning 2XX (success) to HEAD or GET requests (after following any redirects).

@@ -37,5 +37,8 @@ [![Build Status](https://secure.travis-ci.org/jeffbski/wait-on.png?branch=master)](http://travis-ci.org/jeffbski/wait-on)

wait-on https://myserver/foo && NEXT_CMD # wait for https 2XX HEAD
wait-on http-get://localhost:8000/foo && NEXT_CMD # wait for http 2XX GET
wait-on https-get://myserver/foo && NEXT_CMD # wait for https 2XX GET
wait-on tcp:4000 && NEXT_CMD # wait for service to listen on a TCP port
wait-on socket:/path/mysock # wait for service to listen on domain socket
wait-on http://unix:/var/SOCKPATH:/a/foo # wait for http on domain socket
wait-on http://unix:/var/SOCKPATH:/a/foo # wait for http HEAD on domain socket
wait-on http-get://unix:/var/SOCKPATH:/a/foo # wait for http GET on domain socket
```

@@ -61,9 +64,12 @@

file: - regular file (also default type). ex: file:/path/to/file
http: - HTTP HEAD returns 2XX response. ex: http://m.com:90/foo
https: - HTTPS HEAD returns 2XX response. ex: https://my/bar
tcp: - TCP port is listening. ex: 1.2.3.4:9000 or foo.com:700
socket: - Domain Socket is listening. ex: socket:/path/to/sock
For http over socket, use http://unix:SOCK_PATH:URL_PATH
like http://unix:/path/to/sock:/foo/bar
file: - regular file (also default type). ex: file:/path/to/file
http: - HTTP HEAD returns 2XX response. ex: http://m.com:90/foo
https: - HTTPS HEAD returns 2XX response. ex: https://my/bar
http-get: - HTTP GET returns 2XX response. ex: http://m.com:90/foo
https-get: - HTTPS GET returns 2XX response. ex: https://my/bar
tcp: - TCP port is listening. ex: 1.2.3.4:9000 or foo.com:700
socket: - Domain Socket is listening. ex: socket:/path/to/sock
For http over socket, use http://unix:SOCK_PATH:URL_PATH
like http://unix:/path/to/sock:/foo/bar or
http-get://unix:/path/to/sock:/foo/bar

@@ -110,5 +116,8 @@ Standard Options:

'https://my.com/cat',
'http-get://foo.com:8000/bar',
'https-get://my.com/cat',
'tcp:foo.com:8000',
'socket:/my/sock',
'http://unix:/my/sock:/my/url'
'http://unix:/my/sock:/my/url',
'http-get://unix:/my/sock:/my/url'
],

@@ -142,2 +151,3 @@ delay: 1000, // initial delay in ms, default 0

- wait for http(s) resources to return 2XX in response to HEAD request
- wait for http(s) resources to return 2XX in response to GET request
- wait for services to be listening on tcp ports

@@ -144,0 +154,0 @@ - wait for services to be listening on unix domain sockets

@@ -89,2 +89,24 @@ 'use strict';

it('should succeed when http GET resources become available later', function (done) {
var opts = {
resources: [
'http-get://localhost:3011',
'http-get://localhost:3011/foo'
]
};
setTimeout(function () {
httpServer = http.createServer()
.on('request', function (req, res) {
res.end('data');
});
httpServer.listen(3011, 'localhost');
}, 300);
waitOn(opts, function (err) {
expect(err).toNotExist();
done();
});
});
/*

@@ -103,4 +125,18 @@ it('should succeed when an https resource is available', function (done) {

});
it('should succeed when an https GET resource is available', function (done) {
var opts = {
resources: [
'https-get://www.google.com'
]
};
waitOn(opts, function (err) {
expect(err).toNotExist();
done();
});
});
*/
it('should succeed when a service is listening to tcp port', function (done) {

@@ -176,2 +212,28 @@ var opts = {

it('should succeed when a http GET service is listening to a socket', function (done) {
var socketPath;
temp.mkdir({}, function (err, dirPath) {
socketPath = path.resolve(dirPath, 'sock');
var opts = {
resources: [
'http-get://unix:' + socketPath + ':/',
'http-get://unix:' + socketPath + ':/foo'
]
};
setTimeout(function () {
httpServer = http.createServer()
.on('request', function (req, res) {
res.end('data');
});
httpServer.listen(socketPath);
}, 300);
waitOn(opts, function (err) {
expect(err).toNotExist();
done();
});
});
});
// Error situations

@@ -237,3 +299,3 @@

resources: [
'http://localhost:3000'
'http://localhost:3010'
],

@@ -251,6 +313,22 @@ timeout: 1000,

it('should timeout when an http GET resource is not available', function (done) {
var opts = {
resources: [
'http-get://localhost:3010'
],
timeout: 1000,
interval: 100,
window: 100
};
waitOn(opts, function (err) {
expect(err).toExist();
done();
});
});
it('should timeout when an https resource is not available', function (done) {
var opts = {
resources: [
'https://localhost:3000/foo/bar'
'https://localhost:3010/foo/bar'
],

@@ -268,6 +346,22 @@ timeout: 1000,

it('should timeout when an https GET resource is not available', function (done) {
var opts = {
resources: [
'https-get://localhost:3010/foo/bar'
],
timeout: 1000,
interval: 100,
window: 100
};
waitOn(opts, function (err) {
expect(err).toExist();
done();
});
});
it('should timeout when a service is not listening to tcp port', function (done) {
var opts = {
resources: [
'tcp:localhost:3000'
'tcp:localhost:3010'
],

@@ -274,0 +368,0 @@ timeout: 1000

@@ -102,2 +102,25 @@ 'use strict';

it('should succeed when http GET resources become available later', function (done) {
var opts = {
resources: [
'http-get://localhost:8124',
'http-get://localhost:8124/foo'
]
};
setTimeout(function () {
httpServer = http.createServer()
.on('request', function (req, res) {
res.end('data');
});
httpServer.listen(8124, 'localhost');
}, 300);
execCLI(opts.resources.concat(FAST_OPTS), {})
.on('exit', function (code) {
expect(code).toBe(0);
done();
});
});
/*

@@ -192,2 +215,29 @@ it('should succeed when an https resource is available', function (done) {

it('should succeed when a http GET service is listening to a socket', function (done) {
var socketPath;
temp.mkdir({}, function (err, dirPath) {
socketPath = path.resolve(dirPath, 'sock');
var opts = {
resources: [
'http-get://unix:' + socketPath + ':/',
'http-get://unix:' + socketPath + ':/foo'
]
};
setTimeout(function () {
httpServer = http.createServer()
.on('request', function (req, res) {
res.end('data');
});
httpServer.listen(socketPath);
}, 300);
execCLI(opts.resources.concat(FAST_OPTS), {})
.on('exit', function (code) {
expect(code).toBe(0);
done();
});
});
});
// Error situations

@@ -269,6 +319,23 @@

it('should timeout when an http GET resource is not available', function (done) {
var opts = {
resources: [
'http-get://localhost:3999'
],
timeout: 1000,
interval: 100,
window: 100
};
execCLI(opts.resources.concat(FAST_OPTS), {})
.on('exit', function (code) {
expect(code).toNotBe(0);
done();
});
});
it('should timeout when an https resource is not available', function (done) {
var opts = {
resources: [
'https://localhost:3000/foo/bar'
'https://localhost:3010/foo/bar'
],

@@ -287,6 +354,23 @@ timeout: 1000,

it('should timeout when an https GET resource is not available', function (done) {
var opts = {
resources: [
'https-get://localhost:3010/foo/bar'
],
timeout: 1000,
interval: 100,
window: 100
};
execCLI(opts.resources.concat(FAST_OPTS), {})
.on('exit', function (code) {
expect(code).toNotBe(0);
done();
});
});
it('should timeout when a service is not listening to tcp port', function (done) {
var opts = {
resources: [
'tcp:localhost:3000'
'tcp:localhost:3010'
],

@@ -293,0 +377,0 @@ timeout: 1000

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc