Skip to content

Commit

Permalink
Merge pull request #4348 from gabrielcsapo/opn-error-logging
Browse files Browse the repository at this point in the history
[logging] better error logging for when opn fails to opn
  • Loading branch information
gabrielcsapo committed Oct 12, 2018
2 parents 551e7f9 + 9649780 commit fb774e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3,100 deletions.
1 change: 1 addition & 0 deletions lib/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"case-sensitive-paths-webpack-plugin": "^2.1.2",
"chalk": "^2.4.1",
"commander": "^2.19.0",
"common-tags": "^1.8.0",
"core-js": "^2.5.7",
"css-loader": "^1.0.0",
"detect-port": "^1.2.3",
Expand Down
9 changes: 8 additions & 1 deletion lib/core/src/server/build-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import fs from 'fs';
import chalk from 'chalk';
import { logger } from '@storybook/node-logger';
import opn from 'opn';
import { stripIndents } from 'common-tags';
import storybook, { webpackValid } from './middleware';
import { getDevCli } from './cli';
import './config/env';
Expand Down Expand Up @@ -117,7 +118,13 @@ export async function buildDevStandalone(options) {
if (options.smokeTest) {
process.exit(stats.toJson().warnings.length ? 1 : 0);
} else if (!options.ci) {
opn(address);
opn(address).catch(() => {
logger.error(stripIndents`
Could not open ${address} inside a browser. If you're running this command inside a
docker container or on a CI, you need to pass the '--ci' flag to prevent opening a
browser by default.
`);
});
}
} catch (error) {
if (error instanceof Error) {
Expand Down
Loading

0 comments on commit fb774e0

Please sign in to comment.