q9
This commit is contained in:
97
node_modules/wait-on/bin/usage.txt
generated
vendored
Normal file
97
node_modules/wait-on/bin/usage.txt
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
Usage: wait-on {OPTIONS} resource [...resource]
|
||||
|
||||
Description:
|
||||
|
||||
wait-on is a command line utility which will wait for files, ports,
|
||||
sockets, and http(s) resources to become available (or not available
|
||||
using reverse flag). Exits with success code (0) when all resources
|
||||
are ready. Non-zero exit code if interrupted or timed out.
|
||||
|
||||
Options may also be specified in a config file (js or json). For
|
||||
example --config configFile.js would result in configFile.js being
|
||||
required and the resulting object will be merged with any
|
||||
command line options before wait-on is called. See exampleConfig.js
|
||||
|
||||
In shell combine with && to conditionally run another command
|
||||
once resources are available. ex: wait-on f1 && NEXT_CMD
|
||||
|
||||
resources types are defined by their prefix, if no prefix is
|
||||
present, the resource is assumed to be of type 'file'
|
||||
|
||||
resource prefixes are:
|
||||
|
||||
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-get://m.com:90/foo
|
||||
https-get: - HTTPS GET returns 2XX response. ex: https-get://my/bar
|
||||
tcp: - TCP port is listening. ex: tcp:1.2.3.4:9000 or tcp: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:http://server/foo/bar or
|
||||
http-get://unix:/path/to/sock:http://server/foo/bar
|
||||
|
||||
Standard Options:
|
||||
|
||||
-c, --config
|
||||
|
||||
js or json config file, useful for http(s) options
|
||||
|
||||
-d, --delay
|
||||
|
||||
Initial delay before checking for resources in ms, default 0
|
||||
|
||||
--httpTimeout
|
||||
|
||||
Maximum time in ms to wait for an HTTP HEAD/GET request, default 0
|
||||
which results in using the OS default
|
||||
|
||||
-i, --interval
|
||||
|
||||
Interval to poll resources in ms, default 250ms
|
||||
|
||||
-l, --log
|
||||
|
||||
Log resources begin waited on and when complete or errored
|
||||
|
||||
-r, --reverse
|
||||
|
||||
Reverse operation, wait for resources to NOT be available
|
||||
|
||||
-s, --simultaneous
|
||||
|
||||
Simultaneous / Concurrent connections to a resource, default Infinity
|
||||
Setting this to 1 would delay new requests until previous one has completed.
|
||||
Used to limit the number of connections attempted to a resource at a time.
|
||||
|
||||
-t, --timeout
|
||||
|
||||
Maximum time in ms to wait before exiting with failure (1) code,
|
||||
default Infinity
|
||||
Use postfix 'ms', 's', 'm' or 'h' to change the unit.
|
||||
|
||||
--tcpTimeout
|
||||
|
||||
Maximum time in ms for tcp connect, default 300ms
|
||||
Use postfix 'ms', 's', 'm' or 'h' to change the unit.
|
||||
|
||||
--httpTimeout
|
||||
|
||||
Maximum time to wait for the HTTP request, default Infinity
|
||||
Use postfix 'ms', 's', 'm' or 'h' to change the unit.
|
||||
|
||||
-v, --verbose
|
||||
|
||||
Enable debug output to stdout
|
||||
|
||||
-w, --window
|
||||
|
||||
Stability window, the time in ms defining the window of time that
|
||||
resource needs to have not changed (file size/availability) before
|
||||
signaling success, default 750ms. If less than interval, it will be
|
||||
reset to the value of interval. This is only used for files, other
|
||||
resources are considered available on first detection.
|
||||
|
||||
-h, --help
|
||||
|
||||
Show this message
|
||||
101
node_modules/wait-on/bin/wait-on
generated
vendored
Executable file
101
node_modules/wait-on/bin/wait-on
generated
vendored
Executable file
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const minimist = require('minimist');
|
||||
const path = require('path');
|
||||
const waitOn = require('../');
|
||||
|
||||
const interval = ['timeout', 'httpTimeout', 'tcpTimeout'];
|
||||
const minimistOpts = {
|
||||
string: ['c', 'd', 'i', 's', 't', 'w'].concat(interval),
|
||||
boolean: ['h', 'l', 'r', 'v'],
|
||||
alias: {
|
||||
c: 'config',
|
||||
d: 'delay',
|
||||
i: 'interval',
|
||||
l: 'log',
|
||||
r: 'reverse',
|
||||
s: 'simultaneous',
|
||||
t: 'timeout',
|
||||
v: 'verbose',
|
||||
w: 'window',
|
||||
h: 'help'
|
||||
}
|
||||
};
|
||||
|
||||
const argv = minimist(process.argv.slice(2), minimistOpts);
|
||||
// if a js/json configuration file is provided require it
|
||||
const configOpts = argv.config ? require(path.resolve(argv.config)) : {};
|
||||
const hasResources = argv._.length || (configOpts.resources && configOpts.resources.length);
|
||||
|
||||
if (argv.help || !hasResources) {
|
||||
// help
|
||||
fs.createReadStream(path.join(__dirname, '/usage.txt'))
|
||||
.pipe(process.stdout)
|
||||
.on('close', function () {
|
||||
process.exit(1);
|
||||
});
|
||||
} else {
|
||||
// if resources are present in the command line then they take
|
||||
// precedence over those in the config file.
|
||||
if (argv._.length) {
|
||||
configOpts.resources = argv._;
|
||||
}
|
||||
|
||||
// now check for specific options and set those
|
||||
const opts = [
|
||||
'delay',
|
||||
'httpTimeout',
|
||||
'interval',
|
||||
'log',
|
||||
'reverse',
|
||||
'simultaneous',
|
||||
'timeout',
|
||||
'tcpTimeout',
|
||||
'verbose',
|
||||
'window'
|
||||
].reduce(function (accum, x) {
|
||||
if (argv[x]) {
|
||||
let value = argv[x];
|
||||
if (interval.includes(x)) {
|
||||
value = parseInterval(value);
|
||||
}
|
||||
accum[x] = value;
|
||||
}
|
||||
return accum;
|
||||
}, configOpts);
|
||||
|
||||
waitOn(opts, function (err) {
|
||||
if (err) {
|
||||
return errorExit(err);
|
||||
}
|
||||
// success, could just let it exit on its own, however since
|
||||
// rxjs window waits an extra loop before heeding the unsubscribe
|
||||
// we can exit to speed things up
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
function errorExit(err) {
|
||||
if (err.stack) {
|
||||
console.error(err.stack);
|
||||
} else {
|
||||
console.error(String(err));
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function parseInterval(arg) {
|
||||
const res = /^([\d.]+)(|ms|s|m|h)$/i.exec(arg);
|
||||
if (!res) {
|
||||
return arg;
|
||||
}
|
||||
const value = parseFloat(res[1]);
|
||||
switch (res[2]) {
|
||||
case '':
|
||||
case 'ms': return Math.floor(value);
|
||||
case 's': return Math.floor(value * 1000);
|
||||
case 'm': return Math.floor(value * 1000 * 60);
|
||||
case 'h': return Math.floor(value * 1000 * 60 * 60);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user