Skip to content

Commit

Permalink
Merge pull request #195 from zetxx/master
Browse files Browse the repository at this point in the history
feat(host): ability to control host name
  • Loading branch information
Muhammed Thanish committed May 16, 2016
2 parents eb13e1d + a987ba3 commit 52e5b4a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const logger = console;
program
.version(packageJson.version)
.option('-p, --port [number]', 'Port to run Storybook (Required)', parseInt)
.option('-h, --host [string]', 'Host to run Storybook')
.option('-s, --static-dir [dir-name]', 'Directory where to load static files from')
.option('-c, --config-dir [dir-name]', 'Directory where to load Storybook configurations from')
.parse(process.argv);
Expand All @@ -29,6 +30,10 @@ if (!program.port) {
process.exit(-1);
}

if (!program.host) {
program.host = 'localhost';
}

const app = express();

if (program.staticDir) {
Expand Down Expand Up @@ -64,10 +69,10 @@ app.get('/iframe.html', function (req, res) {
res.send(getIframeHtml(headHtml));
});

app.listen(program.port, function (error) {
app.listen(program.port, program.host, function (error) {
if (error) {
throw error;
} else {
logger.info(`\nReact Storybook started on => http://localhost:${program.port}/ \n`);
logger.info(`\nReact Storybook started on => http://${program.host}:${program.port}/ \n`);
}
});

0 comments on commit 52e5b4a

Please sign in to comment.