lib/tools/index.js
function () {
    "use strict";

    return new Promise(function (resolve, reject) {
      var numberOfRetries = 5;

      (function retry () {
        var port = 4000 + Math.floor(Math.random() * 1000);
        portscanner.checkPortStatus(port, 'localhost', function (err, status) {
          if (err || status !== 'closed') {
            if (--numberOfRetries > 0) {
              setTimeout(retry);
            } else {
              reject('Cannot find a free port... giving up');
            }
          } else {
            resolve(port);
          }
        });
      })();
    });
  }
function () {
    "use strict";

    return new Promise(function (resolve, reject) {
      var numberOfRetries = 5;

      (function retry () {
        var port = 4000 + Math.floor(Math.random() * 1000);
        portscanner.checkPortStatus(port, 'localhost', function (err, status) {
          if (err || status !== 'closed') {
            if (--numberOfRetries > 0) {
              setTimeout(retry);
            } else {
              reject('Cannot find a free port... giving up');
            }
          } else {
            resolve(port);
          }
        });
      })();
    });
  }
function ( ) { "use strict" ; return new Promise ( function ( resolve , reject ) { var numberOfRetries = 5 ; ( function retry ( ) { var port = 4000 + Math . floor ( Math . random ( ) * 1000 ) ; portscanner . checkPortStatus ( port , 'localhost' , function ( err , status ) { if ( err || status !== 'closed' ) { if ( -- numberOfRetries > 0 ) { setTimeout ( retry ) ; } else { reject ( 'Cannot find a free port... giving up' ) ; } } else { resolve ( port ) ; } } ) ; } ) ( ) ; } ) ; }
Find a port, nobody is listening on.
Find a port nobody is listening on .