Skip to content

Commit

Permalink
feat: reuse existing chrome tab if possible
Browse files Browse the repository at this point in the history
- Move from open to better-opn
- Feature available on chrome only unfortunately
  • Loading branch information
yannbf committed Apr 6, 2020
1 parent 2d540b9 commit c4000fb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "^1.0.0",
"boxen": "^4.1.0",
"case-sensitive-paths-webpack-plugin": "^2.2.0",
"chalk": "^3.0.0",
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions lib/core/src/server/build-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 9 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7342,6 +7342,13 @@ better-assert@~1.0.0:
dependencies:
callsite "1.0.0"

better-opn@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/better-opn/-/better-opn-1.0.0.tgz#0454e4bb9115c6a9e4e5744417dd9c97fb9fce41"
integrity sha512-q3eO2se4sFbTERB1dFBDdjTiIIpRohMErpwBX21lhPvmgmQNNrcQj0zbWRhMREDesJvyod9kxBS3kOtdAvkB/A==
dependencies:
open "^6.4.0"

bfj@^6.1.1:
version "6.1.2"
resolved "https://registry.yarnpkg.com/bfj/-/bfj-6.1.2.tgz#325c861a822bcb358a41c78a33b8e6e2086dde7f"
Expand Down Expand Up @@ -21679,15 +21686,15 @@ 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:
version "7.0.3"
resolved "https://registry.yarnpkg.com/open/-/open-7.0.3.tgz#db551a1af9c7ab4c7af664139930826138531c48"
integrity sha512-sP2ru2v0P290WFfv49Ap8MF6PkzGNnGlAwHweB4WR4mr5d2d0woiCluUeJ218w7/+PmoBy9JmYgD5A4mLcWOFA==
dependencies:
is-docker "^2.0.0"
is-wsl "^2.1.1"

open@^6.3.0:
open@^6.3.0, open@^6.4.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/open/-/open-6.4.0.tgz#5c13e96d0dc894686164f18965ecfe889ecfc8a9"
integrity sha512-IFenVPgF70fSm1keSd2iDBIDIBZkroLeuffXq+wKTzTJlBpesFWojV9lb8mzOfaAzM1sr7HQHuO0vtV0zYekGg==
Expand Down

0 comments on commit c4000fb

Please sign in to comment.