Skip to content
Permalink
Browse files

[bin dist] Add command line switch for opening the browser

`-o` opens the browser after server is started.
  • Loading branch information...
mmalecki authored and indexzero committed Nov 28, 2013
1 parent 2b0b559 commit 60c681ce4855e53a4657afe86035674fed1a948a
Showing with 11 additions and 4 deletions.
  1. +9 −3 bin/http-server
  2. +2 −1 package.json
@@ -3,7 +3,8 @@
var colors = require('colors'),
httpServer = require('../lib/http-server'),
argv = require('optimist').argv,
portfinder = require('portfinder');
portfinder = require('portfinder'),
opener = require('opener');

if (argv.h || argv.help) {
console.log([
@@ -16,10 +17,11 @@ if (argv.h || argv.help) {
" -i Display autoIndex [true]",
" -e --ext Default file extension if none supplied [none]",
" -s --silent Suppress log messages from output",
" -h --help Print this list and exit.",
" --cors Enable CORS via the 'Access-Control-Allow-Origin' header"

This comment has been minimized.

Copy link
@ionutvmi

ionutvmi Dec 6, 2013

there is a missing column at the end of the line here

" -o Open browser window after staring the server",
" -c Set cache time (in seconds). e.g. -c10 for 10 seconds.",
" To disable caching, use -c-1.",
" --cors Enable CORS via the 'Access-Control-Allow-Origin' header"
" -h --help Print this list and exit."
].join('\n'));
process.exit();
}
@@ -66,6 +68,10 @@ function listen(port) {
+ ' on port: '.yellow
+ port.toString().cyan);
log('Hit CTRL-C to stop the server');

if (argv.o) {
opener('http://127.0.0.1:' + port.toString());
}
});
}

@@ -54,7 +54,8 @@
"optimist": "0.5.x",
"union": "0.3.x",
"ecstatic": "0.4.x",
"portfinder": "0.2.x"
"portfinder": "0.2.x",
"opener": "~1.3.0"
},
"devDependencies": {
"vows": "0.7.x",

0 comments on commit 60c681c

Please sign in to comment.
You can’t perform that action at this time.