sindresorhus / wait-for-localhost

Wait for localhost to be ready
MIT License
273 stars 10 forks source link

API mode #3

Closed simonhaenisch closed 6 years ago

simonhaenisch commented 6 years ago

Hi, would you be willing to add (or accept a PR for) an API mode? Basically just return a promise that resolves once the server is available (I want to use this in a CLI tool).

const waitForLocalhost = require('wait-for-localhost');

(async () => {
  await waitForLocalhost({ port });

  // ready to do some stuff, e. g. access served files
})();

Edit: whoops, just saw that someone already submitted PR #2 for that 🙈

sindresorhus commented 6 years ago

Fixed by https://github.com/sindresorhus/wait-for-localhost/pull/2