wait for files, ports, sockets, http(s) resources.
wait-on is a cross-platform command line and API utility which will wait for files, ports, sockets, and http(s) resources to become available (or not available using reverse mode).
Get it:npm install [-g] wait-on
Sample usage:
12345678910111213141516171819
wait-on file1 && NEXT_CMD # wait for file1, then exec NEXT_CMD wait-on f1 f2 && NEXT_CMD # wait for both f1 and f2, the exec NEXT_CMD wait-on http://localhost:8000/foo && NEXT_CMD # wait for http 2XX HEAD 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 portwait-on socket:/path/mysock # wait for service to listen 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
123456
try{awaitwaitOn(opts);// once here, all resources are available}catch(err){handleError(err);}