Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

expose server objects

  • Loading branch information...
commit e771044892d9901125e342fcac370a5fcf84a4c3 1 parent 00dbd1b
@substack authored
Showing with 17 additions and 11 deletions.
  1. +9 −4 bin/cmd.js
  2. +7 −6 lib/servers.js
  3. +1 −1  package.json
View
13 bin/cmd.js
@@ -14,8 +14,13 @@ var argv = require('optimist')
.argv
;
if (argv._[0] === 'list') {
- launcher.config.read(function (err, cfg) {
+ launcher.config.read(function show (err, cfg) {
if (err) return console.error(err);
+ if (!cfg) {
+ console.error('# detecting browsers for the first time');
+ return launcher.setup(show);
+ }
+
cfg.browsers.local.forEach(function (browser) {
console.log(browser.name + '/' + browser.version);
});
@@ -39,7 +44,7 @@ if (argv.browser === 'node') {
return;
}
-createServers(argv, function (uri, ports) {
+createServers(argv, function (uri, ports, servers) {
if (argv.browser === 'echo') {
console.log([
uri, ' proxy: localhost:' + ports.proxy
@@ -75,8 +80,8 @@ createServers(argv, function (uri, ports) {
launch(uri, opts, function (err, ps) {
if (err) return console.error(err);
ps.on('exit', function () {
- server.close();
- proxy.close();
+ servers.web.close();
+ servers.proxy.close();
});
});
});
View
13 lib/servers.js
@@ -8,8 +8,9 @@ module.exports = function (opts, cb) {
+ '"></script>'
;
- var proxy = insertProxy(script, [ 'http://' + opts.server ]);
- var server = (function () {
+ var servers = {};
+ servers.proxy = insertProxy(script, [ 'http://' + opts.server ]);
+ servers.web = (function () {
var http = require('http');
var ecstatic = require('ecstatic')(__dirname + '/../static');
return http.createServer(function (req, res) {
@@ -34,7 +35,7 @@ module.exports = function (opts, cb) {
.pipe(process.stdout, { end : false })
;
});
- sock.install(server, '/push');
+ sock.install(servers.web, '/push');
var pending = 2;
var ports = {
proxy : parseInt(opts.proxy.split(':')[1], 10),
@@ -42,10 +43,10 @@ module.exports = function (opts, cb) {
};
var uri = 'http://localhost:' + ports.server + '/?' + Math.random();
- proxy.listen(ports.proxy, onready);
- server.listen(ports.server, onready);
+ servers.proxy.listen(ports.proxy, onready);
+ servers.web.listen(ports.server, onready);
function onready () {
- if (--pending === 0) cb(uri, ports);
+ if (--pending === 0) cb(uri, ports, servers);
}
};
View
2  package.json
@@ -27,7 +27,7 @@
"dependencies" : {
"bouncy" : "~1.3.1",
"ecstatic" : "~0.1.6",
- "browser-launcher" : "~0.0.1",
+ "browser-launcher" : "~0.0.2",
"jsonify" : "~0.0.0",
"schoolbus" : "~0.0.1",
"domready" : "~0.2.11",
Please sign in to comment.
Something went wrong with that request. Please try again.