Skip to content

Commit

Permalink
[bin dist] Add command line switch for opening the browser
Browse files Browse the repository at this point in the history
`-o` opens the browser after server is started.
  • Loading branch information
mmalecki authored and indexzero committed Dec 6, 2013
1 parent 2b0b559 commit 60c681c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions bin/http-server
Expand Up @@ -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([
Expand All @@ -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
@mihai-vlc

mihai-vlc 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();
}
Expand Down Expand Up @@ -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());
}
});
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -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",
Expand Down

0 comments on commit 60c681c

Please sign in to comment.