diff --git a/lib/core/package.json b/lib/core/package.json index c34bbbf2153e..740dbbf0c1fd 100644 --- a/lib/core/package.json +++ b/lib/core/package.json @@ -58,6 +58,7 @@ "babel-plugin-emotion": "^10.0.20", "babel-plugin-macros": "^2.8.0", "babel-preset-minify": "^0.5.0 || 0.6.0-alpha.5", + "better-opn": "^2.0.0", "boxen": "^4.1.0", "case-sensitive-paths-webpack-plugin": "^2.2.0", "chalk": "^3.0.0", @@ -85,7 +86,6 @@ "lazy-universal-dotenv": "^3.0.1", "micromatch": "^4.0.2", "node-fetch": "^2.6.0", - "open": "^7.0.1", "pkg-dir": "^4.2.0", "pnp-webpack-plugin": "1.6.4", "postcss-flexbugs-fixes": "^4.1.0", diff --git a/lib/core/src/server/build-dev.js b/lib/core/src/server/build-dev.js index 7c4a049e4e24..58e02713225a 100644 --- a/lib/core/src/server/build-dev.js +++ b/lib/core/src/server/build-dev.js @@ -9,7 +9,7 @@ import chalk from 'chalk'; import { logger, colors, instance as npmLog } from '@storybook/node-logger'; import fetch from 'node-fetch'; import Cache from 'file-system-cache'; -import open from 'open'; +import open from 'better-opn'; import boxen from 'boxen'; import semver from 'semver'; import dedent from 'ts-dedent'; @@ -234,13 +234,15 @@ async function outputStats(previewStats, managerStats) { } function openInBrowser(address) { - open(address).catch(() => { + try { + open(address); + } catch (error) { logger.error(dedent` 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. `); - }); + } } export async function buildDevStandalone(options) { diff --git a/yarn.lock b/yarn.lock index a92157457966..da3f8a341a7d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7342,6 +7342,13 @@ better-assert@~1.0.0: dependencies: callsite "1.0.0" +better-opn@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/better-opn/-/better-opn-2.0.0.tgz#c70d198e51164bdc220306a28a885d9ac7a14c44" + integrity sha512-PPbGRgO/K0LowMHbH/JNvaV3qY3Vt+A2nH28fzJxy16h/DfR5OsVti6ldGl6S9SMsyUqT13sltikiAVtI6tKLA== + dependencies: + open "^7.0.3" + bfj@^6.1.1: version "6.1.2" resolved "https://registry.yarnpkg.com/bfj/-/bfj-6.1.2.tgz#325c861a822bcb358a41c78a33b8e6e2086dde7f" @@ -21679,7 +21686,7 @@ onetime@^5.1.0: dependencies: mimic-fn "^2.1.0" -open@7.0.3, open@^7.0.1, open@^7.0.2: +open@7.0.3, open@^7.0.2, open@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/open/-/open-7.0.3.tgz#db551a1af9c7ab4c7af664139930826138531c48" integrity sha512-sP2ru2v0P290WFfv49Ap8MF6PkzGNnGlAwHweB4WR4mr5d2d0woiCluUeJ218w7/+PmoBy9JmYgD5A4mLcWOFA==