Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open browser with URL provided in -o [path] #234

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 11 additions & 5 deletions bin/http-server
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,19 @@ function listen(port) {
logger.info('Unhandled requests will be served from: ' + proxy);
}

logger.info('Hit CTRL-C to stop the server');
if (argv.o) {
opener(
protocol + '//' + canonicalHost + ':' + port,
{ command: argv.o !== true ? argv.o : null }
);
var hostUrl = protocol + canonicalHost + ':' + port;
if (typeof argv.o === 'string') {
hostUrl += argv.o.charAt(0) === '/' ? argv.o : '/' + argv.o;
opener(hostUrl);
}
else {
opener(hostUrl, { command: argv.o !== true ? argv.o : null });
}
logger.info('Opened browser:'.yellow);
logger.info((' ' + hostUrl).green);
}
logger.info('Hit CTRL-C to stop the server');
});
}

Expand Down