import pf from 'portfinder';


export function homedir() {
  return process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
}


export function wait (time) {
  return new Promise(resolve => {
    setTimeout(() => resolve(), time);
  });
}


export function getPort () {
  return new Promise((resolve, reject) => {
    pf.getPort((err, port) => {
      if (err) return reject(err);
      resolve(port);
    });
  });
}

import fs from 'fs';
import pf from 'portfinder';


export function homedir() {
  return process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
}


export function wait (time) {
  return new Promise(resolve => {
    setTimeout(() => resolve(), time);
  });
}


export function getPort () {
  return new Promise((resolve, reject) => {
    pf.getPort({ host: '127.0.0.1' }, (err, port) => {
      if (err) return reject(err);
      resolve(port);
    });
  });
}


export function readFile (filename) {
  return new Promise((resolve, reject) => {
    fs.readFile(filename, (err, data) => {
      if (err) return reject(err);
      resolve(data);
    });
  });
}

Fix getPort and add readFile
Fix getPort and add readFile

getPort was considering bind to 0.0.0.0 instead of 127.0.0.1.
readFile added to provide a promise-based version of fs.readFile