can-bind-to-host
Version:
Utility package to see if the node process can bind to the host or listen on a port. Can be used for checking if a host resolves to localhost.
20 lines (19 loc) • 719 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var __1 = __importDefault(require(".."));
var args = process.argv.slice(2);
var _a = args[0], host = _a === void 0 ? '0.0.0.0' : _a, _b = args[1], port = _b === void 0 ? '0' : _b;
(0, __1.default)(host, +port).then(function (bindable) {
if (bindable) {
console.log("".concat(host, ":").concat(port, " is bindable"));
process.exit(0);
}
else {
console.log("".concat(host, ":").concat(port, " is not bindable"));
process.exit(1);
}
});