@zohodesk/client_build_tool
Version:
A CLI tool to build web applications and client libraries
30 lines (23 loc) • 646 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getIp = getIp;
var _os = _interopRequireDefault(require("os"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getIp() {
const ifaces = _os.default.networkInterfaces();
let ips = [];
Object.keys(ifaces).forEach(ifname => {
const a = ifaces[ifname].map(iface => {
if (iface.family !== 'IPv4' || iface.internal !== false) {
return null;
}
return iface.address;
}).filter(a => a);
ips = ips.concat(a);
});
ips.push('127.0.0.1');
return ips[0];
}
;