tunnel.js 950 B

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. var _ = require("./lodash.custom");
  3. var utils = require("util");
  4. /**
  5. * @param {BrowserSync} bs
  6. * @param {Function} cb
  7. */
  8. module.exports = function (bs, cb) {
  9. var opts = {};
  10. var options = bs.options;
  11. var port = options.get("port");
  12. if (_.isString(options.get("tunnel"))) {
  13. opts.subdomain = options.get("tunnel");
  14. }
  15. bs.debug("Requesting a tunnel connection on port: {magenta:%s}", port);
  16. bs.debug("Requesting a tunnel connection with options: {magenta:%s}", utils.inspect(opts));
  17. require("localtunnel")(port, opts, function (err, tunnel) {
  18. if (err) {
  19. return cb(err);
  20. }
  21. tunnel.on("error", function (err) {
  22. bs.logger.info("Localtunnel issue: " + err.message);
  23. bs.logger.info("Oops! The localtunnel appears to have disconnected. Reconnecting...");
  24. });
  25. return cb(null, tunnel);
  26. });
  27. };
  28. //# sourceMappingURL=tunnel.js.map