-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tunnel): Switch to ngrok - re: #192
- Loading branch information
1 parent
29c9bd3
commit 7359435
Showing
6 changed files
with
178 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
"use strict"; | ||
|
||
var _ = require("lodash"); | ||
var localTunnel = require("localtunnel"); | ||
var utils = require("util"); | ||
var ngrok = require("ngrok"); | ||
var utils = require("util"); | ||
|
||
/** | ||
* @param {BrowserSync} bs | ||
* @param {Function} cb | ||
*/ | ||
module.exports = function (bs, cb) { | ||
|
||
var opts = {}; | ||
var options = bs.options; | ||
var port = options.get("port"); | ||
|
||
if (_.isString(options.get("tunnel"))) { | ||
opts.subdomain = options.get("tunnel"); | ||
} | ||
var opts = options.get("tunnel"); | ||
|
||
bs.debug("Requesting a tunnel connection on port: {magenta:%s}", port); | ||
bs.debug("Requesting a tunnel connection with options: {magenta:%s}", utils.inspect(opts)); | ||
|
||
localTunnel(port, opts, function (err, tunnel) { | ||
ngrok.connect(opts.set("port", port).toJS(), function (err, url) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
return cb(null, tunnel); | ||
return cb(null, url); | ||
}); | ||
return ngrok; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"use strict"; | ||
|
||
var path = require("path"); | ||
var assert = require("chai").assert; | ||
var browserSync = require(path.resolve("./")); | ||
|
||
var pkg = require(path.resolve("package.json")); | ||
var cli = require(path.resolve(pkg.bin)); | ||
|
||
describe("E2E CLI server + tunnel test", function () { | ||
|
||
var bs; | ||
|
||
before(function (done) { | ||
|
||
browserSync.reset(); | ||
|
||
cli({ | ||
cli: { | ||
input: ["start"], | ||
flags: { | ||
server: "test/fixtures", | ||
open: false, | ||
online: true, | ||
logLevel: "silent", | ||
tunnel: true | ||
} | ||
}, | ||
cb: function (err, out) { | ||
bs = out; | ||
done(); | ||
} | ||
}); | ||
}); | ||
after(function () { | ||
bs.cleanup(); | ||
bs.tunnel.disconnect(); | ||
}); | ||
it("should call init on the tunnel", function () { | ||
assert.include(bs.getOptionIn(["urls", "tunnel"]), "ngrok.com"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters