diff --git a/README.md b/README.md index 4158d1d3..e717739a 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ This will install `http-server` globally so that it may be run from the command `-o` Open browser window after starting the server +`-b` or `--baseDir` If -o is used then open given base dir. e.g.: `hs -o -b docs` => http://127.0.0.1:8080/docs + `-c` Set cache time (in seconds) for cache-control max-age header, e.g. `-c10` for 10 seconds (defaults to `3600`). To disable caching, use `-c-1`. `-U` or `--utc` Use UTC time format in log messages. diff --git a/bin/http-server b/bin/http-server index 0a1f2e94..5676737b 100755 --- a/bin/http-server +++ b/bin/http-server @@ -27,7 +27,8 @@ if (argv.h || argv.help) { ' -s --silent Suppress log messages from output', ' --cors[=headers] Enable CORS via the "Access-Control-Allow-Origin" header', ' Optionally provide CORS headers list separated by commas', - ' -o [path] Open browser window after starting the server', + ' -o [cmd] Open browser window after starting the server', + ' -b --baseDir If -o then open that base dir. e.g.: docs => http://127.0.0.1:8080/docs', ' -c Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds.', ' To disable caching, use -c-1.', ' -U --utc Use UTC time format in log messages.', @@ -151,7 +152,7 @@ function listen(port) { logger.info('Hit CTRL-C to stop the server'); if (argv.o) { opener( - protocol + canonicalHost + ':' + port, + protocol + canonicalHost + ':' + port + (argv.b ? '/' + argv.b : ''), { command: argv.o !== true ? argv.o : null } ); }